httparty 0.14.0 → 0.15.0

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.

@@ -72,6 +72,18 @@ RSpec.describe HTTParty::Response do
72
72
  end
73
73
  end
74
74
 
75
+ it 'does raise an error about itself when using #method' do
76
+ expect {
77
+ HTTParty::Response.new(@request_object, @response_object, @parsed_response).method(:qux)
78
+ }.to raise_error(NameError, /HTTParty\:\:Response/)
79
+ end
80
+
81
+ it 'does raise an error about itself when invoking a method that does not exist' do
82
+ expect {
83
+ HTTParty::Response.new(@request_object, @response_object, @parsed_response).qux
84
+ }.to raise_error(NoMethodError, /HTTParty\:\:Response/)
85
+ end
86
+
75
87
  it "returns response headers" do
76
88
  response = HTTParty::Response.new(@request_object, @response_object, @parsed_response)
77
89
  expect(response.headers).to eq({'last-modified' => [@last_modified], 'content-length' => [@content_length]})
@@ -117,12 +129,32 @@ RSpec.describe HTTParty::Response do
117
129
  expect(response.respond_to?(:[])).to be_truthy
118
130
  end
119
131
 
120
- it "should be able to iterate if it is array" do
121
- response = HTTParty::Response.new(@request_object, @response_object, lambda { [{'foo' => 'bar'}, {'foo' => 'baz'}] })
122
- expect(response.size).to eq(2)
123
- expect {
124
- response.each { |item| }
125
- }.to_not raise_error
132
+ context 'response is array' do
133
+ let(:response_value) { [{'foo' => 'bar'}, {'foo' => 'baz'}] }
134
+ let(:response) { HTTParty::Response.new(@request_object, @response_object, lambda { response_value }) }
135
+ it "should be able to iterate" do
136
+ expect(response.size).to eq(2)
137
+ expect {
138
+ response.each { |item| }
139
+ }.to_not raise_error
140
+ end
141
+
142
+ it 'should respond to array methods' do
143
+ expect(response).to respond_to(:bsearch, :compact, :cycle, :delete, :each, :flatten, :flatten!, :compact, :join)
144
+ end
145
+
146
+ it 'should equal the string response object body' do
147
+ expect(response.to_s).to eq(@response_object.body.to_s)
148
+ end
149
+
150
+ it 'should display the same as an array' do
151
+ a = StringIO.new
152
+ b = StringIO.new
153
+ response_value.display(b)
154
+ response.display(a)
155
+
156
+ expect(a.string).to eq(b.string)
157
+ end
126
158
  end
127
159
 
128
160
  it "allows headers to be accessed by mixed-case names in hash notation" do
@@ -151,8 +183,7 @@ RSpec.describe HTTParty::Response do
151
183
 
152
184
  it { is_expected.to respond_to(:is_a?).with(1).arguments }
153
185
  it { expect(subject.is_a?(HTTParty::Response)).to be_truthy }
154
- it { expect(subject.is_a?(BasicObject)).to be_truthy }
155
- it { expect(subject.is_a?(Object)).to be_falsey }
186
+ it { expect(subject.is_a?(Object)).to be_truthy }
156
187
  end
157
188
 
158
189
  describe "#kind_of?" do
@@ -160,8 +191,7 @@ RSpec.describe HTTParty::Response do
160
191
 
161
192
  it { is_expected.to respond_to(:kind_of?).with(1).arguments }
162
193
  it { expect(subject.kind_of?(HTTParty::Response)).to be_truthy }
163
- it { expect(subject.kind_of?(BasicObject)).to be_truthy }
164
- it { expect(subject.kind_of?(Object)).to be_falsey }
194
+ it { expect(subject.kind_of?(Object)).to be_truthy }
165
195
  end
166
196
 
167
197
  describe "semantic methods for response codes" do
@@ -263,9 +293,35 @@ RSpec.describe HTTParty::Response do
263
293
  end
264
294
 
265
295
  describe "headers" do
266
- it "can initialize without headers" do
267
- headers = HTTParty::Response::Headers.new
268
- expect(headers).to eq({})
296
+ let (:empty_headers) { HTTParty::Response::Headers.new }
297
+ let (:some_headers_hash) do
298
+ {'Cookie' => 'bob',
299
+ 'Content-Encoding' => 'meow'}
300
+ end
301
+ let (:some_headers) do
302
+ HTTParty::Response::Headers.new.tap do |h|
303
+ some_headers_hash.each_pair do |k,v|
304
+ h[k] = v
305
+ end
306
+ end
307
+ end
308
+ it "can initialize without headers" do
309
+ expect(empty_headers).to eq({})
310
+ end
311
+
312
+ it 'always equals itself' do
313
+ expect(empty_headers).to eq(empty_headers)
314
+ expect(some_headers).to eq(some_headers)
315
+ end
316
+
317
+ it 'does not equal itself when not equivalent' do
318
+ expect(empty_headers).to_not eq(some_headers)
319
+ end
320
+
321
+ it 'does equal a hash' do
322
+ expect(empty_headers).to eq({})
323
+
324
+ expect(some_headers).to eq(some_headers_hash)
269
325
  end
270
326
  end
271
327
 
@@ -129,6 +129,11 @@ RSpec.describe HTTParty do
129
129
  .and_return(double("mock response", perform: nil))
130
130
  end
131
131
 
132
+ it "does not modify default_options when no arguments are passed" do
133
+ @klass.headers
134
+ expect(@klass.default_options[:headers]).to eq(nil)
135
+ end
136
+
132
137
  it "should default to empty hash" do
133
138
  expect(@klass.headers).to eq({})
134
139
  end
@@ -171,11 +176,11 @@ RSpec.describe HTTParty do
171
176
  @klass.get('', cookies: {type: 'snickerdoodle'})
172
177
  end
173
178
 
174
- it 'doesnt modify default_options' do
179
+ it 'doesnt modify default headers' do
175
180
  expect(@klass.headers).to eq({})
176
181
  expect_headers('cookie' => 'type=snickerdoodle')
177
182
  @klass.get('', cookies: {type: 'snickerdoodle'})
178
- expect(@klass.default_options[:headers]).to eq({})
183
+ expect(@klass.headers).to eq({})
179
184
  end
180
185
 
181
186
  it 'adds optional cookies to the optional headers' do
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.14.0
4
+ version: 0.15.0
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: 2016-07-25 00:00:00.000000000 Z
12
+ date: 2017-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_xml
@@ -41,7 +41,7 @@ files:
41
41
  - CONTRIBUTING.md
42
42
  - Gemfile
43
43
  - Guardfile
44
- - History
44
+ - History.md
45
45
  - MIT-LICENSE
46
46
  - README.md
47
47
  - Rakefile
@@ -61,6 +61,7 @@ files:
61
61
  - examples/rescue_json.rb
62
62
  - examples/rubyurl.rb
63
63
  - examples/stackexchange.rb
64
+ - examples/stream_download.rb
64
65
  - examples/tripit_sign_in.rb
65
66
  - examples/twitter.rb
66
67
  - examples/whoismyrep.rb
@@ -142,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
143
  requirements:
143
144
  - - ">="
144
145
  - !ruby/object:Gem::Version
145
- version: 1.9.3
146
+ version: 2.0.0
146
147
  required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  requirements:
148
149
  - - ">="
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  version: '0'
151
152
  requirements: []
152
153
  rubyforge_project:
153
- rubygems_version: 2.4.5.1
154
+ rubygems_version: 2.5.2
154
155
  signing_key:
155
156
  specification_version: 4
156
157
  summary: Makes http fun! Also, makes consuming restful web services dead easy.
@@ -1,16 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIICbTCCAdagAwIBAgIJAIAeO9TXtJ45MA0GCSqGSIb3DQEBBQUAMC4xLDAqBgNV
3
- BAMTI0lOU0VDVVJFIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MCAXDTEwMTAy
4
- MDEzNDYyM1oYDzQ3NDgwOTE1MTM0NjIzWjAuMSwwKgYDVQQDEyNJTlNFQ1VSRSBU
5
- ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
6
- gYkCgYEA3lkBcd352qiIIzqnyvvJj59cx1dnzMyjnuaK2cRH420rBfukLE2MbOVr
7
- 9nYq/7CdjqXpE8uFAF+UTSIK6MWZ/bidkr2xd/et/Ce2pVIVxH+rt3pJz3wZhC3H
8
- Yz+HU4CD2iI9wAzsb6mMV7md1fjlYfir4SBGGPTkcqUJUp2/tQMCAwEAAaOBkDCB
9
- jTAdBgNVHQ4EFgQUy0Lz6RgmtpywlBOXdPABQArp358wXgYDVR0jBFcwVYAUy0Lz
10
- 6RgmtpywlBOXdPABQArp35+hMqQwMC4xLDAqBgNVBAMTI0lOU0VDVVJFIFRlc3Qg
11
- Q2VydGlmaWNhdGUgQXV0aG9yaXR5ggkAgB471Ne0njkwDAYDVR0TBAUwAwEB/zAN
12
- BgkqhkiG9w0BAQUFAAOBgQCmi3JQm+EIWjkRlyz9sijkYS+Ps4opmd/weeaXwa4E
13
- gVBWJGyiduB+kBnfv61+/tDjlrbjBDH5dP8suczHQL8gox4zGgjw64KH4o1ujZYR
14
- cEPbhnUpwbXu7yItlajBZfpFefjF5P0Ao2iEzQldDy0D6nQ19h5QANvQxqweTPQp
15
- pw==
16
- -----END CERTIFICATE-----