httparty 0.15.4 → 0.15.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 719a35806296e11c532ef8d283a1e8548da74cc6
4
- data.tar.gz: 3f4b75c1eb74d848567010da60fe02cf12d6eeeb
3
+ metadata.gz: 3abfd0d8679e4054bc591215e90d767d5024cbf6
4
+ data.tar.gz: 38fa4872a3e9cef824a947443b5d7eb3bb04a709
5
5
  SHA512:
6
- metadata.gz: f37c05926db73533186f453bd7b1b258b7e1da0bd6ec11baf7a46f56a5679ca34e3d2645837747a5343c12c2dfbb036e86b8ef33a4f59544657a98ab362ac6fe
7
- data.tar.gz: 1fe1275d5477089a7c501ca6dbb15cf2db55f85ca92b49d2fa3ceb7d35429d764a9bdd3b1cff66ec20a6d79901bb8c91dde5f9ded3abf0fa1c2f23047f6fe969
6
+ metadata.gz: b398852558384d98d88f73c750e9e41ec93ae631b7f7de00f382d11087b70eae9ccf620a3cd99513f8b926caa97af5f7f3d6ec319b984c004759fad2a3cd22fe
7
+ data.tar.gz: bb01e3e75b9cf968aa6196843e66366679b0242833a89e488e6d589f67083cd4fde486bfeef56fd32386da214107e8dc9e10b3d482f8dca0496257e9b5e388ca
@@ -1,3 +1,9 @@
1
+ ## 0.15.5
2
+
3
+ Fixed
4
+
5
+ * [Use non-destructive gsub](https://github.com/jnunemaker/httparty/pull/540)
6
+
1
7
  ## 0.15.4
2
8
 
3
9
  Fixed
@@ -102,7 +102,7 @@ module HTTParty
102
102
  return nil if body == "null"
103
103
  return nil if body.valid_encoding? && body.strip.empty?
104
104
  if body.valid_encoding? && body.encoding == Encoding::UTF_8
105
- body.gsub!(/\A#{UTF8_BOM}/, '')
105
+ @body = body.gsub(/\A#{UTF8_BOM}/, '')
106
106
  end
107
107
  if supports_format?
108
108
  parse_supported_format
@@ -1,3 +1,3 @@
1
1
  module HTTParty
2
- VERSION = "0.15.4"
2
+ VERSION = "0.15.5"
3
3
  end
@@ -63,57 +63,62 @@ RSpec.describe HTTParty::Parser do
63
63
  end
64
64
 
65
65
  describe "#parse" do
66
- before do
67
- @parser = HTTParty::Parser.new('body', :json)
68
- end
69
-
70
66
  it "attempts to parse supported formats" do
71
- allow(@parser).to receive_messages(supports_format?: true)
72
- expect(@parser).to receive(:parse_supported_format)
73
- @parser.parse
67
+ parser = HTTParty::Parser.new('body', :json)
68
+ allow(parser).to receive_messages(supports_format?: true)
69
+
70
+ expect(parser).to receive(:parse_supported_format)
71
+ parser.parse
74
72
  end
75
73
 
76
74
  it "returns the unparsed body when the format is unsupported" do
77
- allow(@parser).to receive_messages(supports_format?: false)
78
- expect(@parser.parse).to eq(@parser.body)
75
+ parser = HTTParty::Parser.new('body', :json)
76
+ allow(parser).to receive_messages(supports_format?: false)
77
+
78
+ expect(parser.parse).to eq(parser.body)
79
79
  end
80
80
 
81
81
  it "returns nil for an empty body" do
82
- allow(@parser).to receive_messages(body: '')
83
- expect(@parser.parse).to be_nil
82
+ parser = HTTParty::Parser.new('', :json)
83
+ expect(parser.parse).to be_nil
84
84
  end
85
85
 
86
86
  it "returns nil for a nil body" do
87
- allow(@parser).to receive_messages(body: nil)
88
- expect(@parser.parse).to be_nil
87
+ parser = HTTParty::Parser.new(nil, :json)
88
+ expect(parser.parse).to be_nil
89
89
  end
90
90
 
91
91
  it "returns nil for a 'null' body" do
92
- allow(@parser).to receive_messages(body: "null")
93
- expect(@parser.parse).to be_nil
92
+ parser = HTTParty::Parser.new("null", :json)
93
+ expect(parser.parse).to be_nil
94
94
  end
95
95
 
96
96
  it "returns nil for a body with spaces only" do
97
- allow(@parser).to receive_messages(body: " ")
98
- expect(@parser.parse).to be_nil
97
+ parser = HTTParty::Parser.new(" ", :json)
98
+ expect(parser.parse).to be_nil
99
99
  end
100
100
 
101
101
  it "does not raise exceptions for bodies with invalid encodings" do
102
- allow(@parser).to receive_messages(body: "\x80")
103
- allow(@parser).to receive_messages(supports_format?: false)
104
- expect(@parser.parse).to_not be_nil
102
+ parser = HTTParty::Parser.new("\x80", :invalid_format)
103
+ expect(parser.parse).to_not be_nil
105
104
  end
106
105
 
107
106
  it "ignores utf-8 bom" do
108
- allow(@parser).to receive_messages(body: "\xEF\xBB\xBF\{\"hi\":\"yo\"\}")
109
- expect(@parser.parse).to eq({"hi"=>"yo"})
107
+ parser = HTTParty::Parser.new("\xEF\xBB\xBF\{\"hi\":\"yo\"\}", :json)
108
+ expect(parser.parse).to eq({"hi"=>"yo"})
110
109
  end
111
110
 
112
111
  it "parses ascii 8bit encoding" do
113
- allow(@parser).to receive_messages(
114
- body: "{\"currency\":\"\xE2\x82\xAC\"}".force_encoding('ASCII-8BIT')
112
+ parser = HTTParty::Parser.new(
113
+ "{\"currency\":\"\xE2\x82\xAC\"}".force_encoding('ASCII-8BIT'),
114
+ :json
115
115
  )
116
- expect(@parser.parse).to eq({"currency" => "€"})
116
+ expect(parser.parse).to eq({"currency" => "€"})
117
+ end
118
+
119
+ it "parses frozen strings" do
120
+ parser = HTTParty::Parser.new('{"a":1}'.freeze, :json)
121
+ expect(parser.parse).to eq("a" => 1)
117
122
  end
118
123
  end
119
124
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.4
4
+ version: 0.15.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-17 00:00:00.000000000 Z
12
+ date: 2017-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_xml