webmock 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile +2 -7
  4. data/README.md +54 -53
  5. data/Rakefile +1 -1
  6. data/lib/webmock/callback_registry.rb +1 -1
  7. data/lib/webmock/http_lib_adapters/curb_adapter.rb +68 -6
  8. data/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +4 -4
  9. data/lib/webmock/http_lib_adapters/excon_adapter.rb +9 -9
  10. data/lib/webmock/http_lib_adapters/http_rb/request.rb +2 -2
  11. data/lib/webmock/http_lib_adapters/http_rb/response.rb +5 -5
  12. data/lib/webmock/http_lib_adapters/http_rb/webmock.rb +3 -3
  13. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +5 -5
  14. data/lib/webmock/http_lib_adapters/manticore_adapter.rb +7 -7
  15. data/lib/webmock/http_lib_adapters/net_http.rb +3 -3
  16. data/lib/webmock/http_lib_adapters/patron_adapter.rb +4 -4
  17. data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +14 -14
  18. data/lib/webmock/matchers/hash_including_matcher.rb +1 -1
  19. data/lib/webmock/rack_response.rb +3 -3
  20. data/lib/webmock/request_pattern.rb +8 -8
  21. data/lib/webmock/request_stub.rb +5 -5
  22. data/lib/webmock/util/uri.rb +2 -2
  23. data/lib/webmock/version.rb +1 -1
  24. data/minitest/webmock_spec.rb +3 -3
  25. data/spec/acceptance/curb/curb_spec.rb +64 -47
  26. data/spec/acceptance/curb/curb_spec_helper.rb +4 -4
  27. data/spec/acceptance/em_http_request/em_http_request_spec.rb +32 -32
  28. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +9 -9
  29. data/spec/acceptance/excon/excon_spec.rb +14 -14
  30. data/spec/acceptance/excon/excon_spec_helper.rb +6 -6
  31. data/spec/acceptance/http_rb/http_rb_spec.rb +1 -1
  32. data/spec/acceptance/http_rb/http_rb_spec_helper.rb +7 -7
  33. data/spec/acceptance/httpclient/httpclient_spec.rb +20 -20
  34. data/spec/acceptance/httpclient/httpclient_spec_helper.rb +5 -5
  35. data/spec/acceptance/manticore/manticore_spec.rb +11 -11
  36. data/spec/acceptance/manticore/manticore_spec_helper.rb +3 -3
  37. data/spec/acceptance/net_http/net_http_shared.rb +4 -4
  38. data/spec/acceptance/net_http/net_http_spec.rb +25 -25
  39. data/spec/acceptance/net_http/net_http_spec_helper.rb +4 -4
  40. data/spec/acceptance/net_http/real_net_http_spec.rb +1 -1
  41. data/spec/acceptance/patron/patron_spec.rb +10 -10
  42. data/spec/acceptance/patron/patron_spec_helper.rb +5 -5
  43. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +36 -36
  44. data/spec/acceptance/shared/callbacks.rb +11 -11
  45. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +5 -5
  46. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +4 -4
  47. data/spec/acceptance/shared/precedence_of_stubs.rb +4 -4
  48. data/spec/acceptance/shared/request_expectations.rb +90 -90
  49. data/spec/acceptance/shared/returning_declared_responses.rb +49 -49
  50. data/spec/acceptance/shared/stubbing_requests.rb +78 -78
  51. data/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +11 -11
  52. data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +8 -8
  53. data/spec/spec_helper.rb +6 -3
  54. data/spec/support/webmock_server.rb +1 -1
  55. data/spec/unit/api_spec.rb +2 -2
  56. data/spec/unit/errors_spec.rb +3 -3
  57. data/spec/unit/matchers/hash_including_matcher_spec.rb +16 -16
  58. data/spec/unit/rack_response_spec.rb +2 -2
  59. data/spec/unit/request_body_diff_spec.rb +1 -1
  60. data/spec/unit/request_execution_verifier_spec.rb +1 -1
  61. data/spec/unit/request_pattern_spec.rb +115 -115
  62. data/spec/unit/request_signature_snippet_spec.rb +2 -2
  63. data/spec/unit/request_signature_spec.rb +16 -16
  64. data/spec/unit/request_stub_spec.rb +20 -20
  65. data/spec/unit/response_spec.rb +28 -28
  66. data/spec/unit/stub_registry_spec.rb +10 -10
  67. data/spec/unit/stub_request_snippet_spec.rb +6 -6
  68. data/spec/unit/util/hash_keys_stringifier_spec.rb +4 -4
  69. data/spec/unit/util/query_mapper_spec.rb +2 -2
  70. data/spec/unit/util/uri_spec.rb +1 -1
  71. data/test/http_request.rb +3 -3
  72. data/test/shared_test.rb +6 -6
  73. data/webmock.gemspec +4 -2
  74. metadata +32 -4
@@ -4,7 +4,7 @@ describe WebMock::StubRequestSnippet do
4
4
  describe "to_s" do
5
5
  describe "GET" do
6
6
  before(:each) do
7
- @request_signature = WebMock::RequestSignature.new(:get, "www.example.com/?a=b&c=d", :headers => {})
7
+ @request_signature = WebMock::RequestSignature.new(:get, "www.example.com/?a=b&c=d", headers: {})
8
8
  end
9
9
 
10
10
  it "should print stub request snippet with url with params and method and empty successful response" do
@@ -53,7 +53,7 @@ describe WebMock::StubRequestSnippet do
53
53
  it "should not print to_return part if not wanted" do
54
54
  expected = 'stub_request(:get, "http://www.example.com/").'+
55
55
  "\n with(:body => \"abcdef\")"
56
- stub = WebMock::RequestStub.new(:get, "www.example.com").with(:body => "abcdef").to_return(:body => "hello")
56
+ stub = WebMock::RequestStub.new(:get, "www.example.com").with(body: "abcdef").to_return(body: "hello")
57
57
  expect(WebMock::StubRequestSnippet.new(stub).to_s(false)).to eq(expected)
58
58
  end
59
59
  end
@@ -63,8 +63,8 @@ describe WebMock::StubRequestSnippet do
63
63
  let(:multipart_form_body) { 'complicated stuff--ABC123--goes here' }
64
64
  it "should print stub request snippet with body as a hash using rails conventions on form posts" do
65
65
  @request_signature = WebMock::RequestSignature.new(:post, "www.example.com",
66
- :headers => {'Content-Type' => 'application/x-www-form-urlencoded'},
67
- :body => form_body)
66
+ headers: {'Content-Type' => 'application/x-www-form-urlencoded'},
67
+ body: form_body)
68
68
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
69
69
  expected = <<-STUB
70
70
  stub_request(:post, "http://www.example.com/").
@@ -77,8 +77,8 @@ stub_request(:post, "http://www.example.com/").
77
77
 
78
78
  it "should print stub request snippet leaving body as string when not a urlencoded form" do
79
79
  @request_signature = WebMock::RequestSignature.new(:post, "www.example.com",
80
- :headers => {'Content-Type' => 'multipart/form-data; boundary=ABC123'},
81
- :body => multipart_form_body)
80
+ headers: {'Content-Type' => 'multipart/form-data; boundary=ABC123'},
81
+ body: multipart_form_body)
82
82
  @request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
83
83
  expected = <<-STUB
84
84
  stub_request(:post, "http://www.example.com/").
@@ -4,10 +4,10 @@ describe WebMock::Util::HashKeysStringifier do
4
4
 
5
5
  it "should recursively stringify all symbol keys" do
6
6
  hash = {
7
- :a => {
8
- :b => [
7
+ a: {
8
+ b: [
9
9
  {
10
- :c => [{:d => "1"}]
10
+ c: [{d: "1"}]
11
11
  }
12
12
  ]
13
13
  }
@@ -21,7 +21,7 @@ describe WebMock::Util::HashKeysStringifier do
21
21
  ]
22
22
  }
23
23
  }
24
- expect(WebMock::Util::HashKeysStringifier.stringify_keys!(hash, :deep => true)).to eq(stringified)
24
+ expect(WebMock::Util::HashKeysStringifier.stringify_keys!(hash, deep: true)).to eq(stringified)
25
25
  end
26
26
 
27
27
  end
@@ -6,7 +6,7 @@ describe WebMock::Util::QueryMapper do
6
6
  context '#query_to_values' do
7
7
  it 'should raise on invalid notation' do
8
8
  query = 'a=&b=c'
9
- expect { subject.query_to_values(query, {:notation => 'foo'}) }.to raise_error(
9
+ expect { subject.query_to_values(query, {notation: 'foo'}) }.to raise_error(
10
10
  ArgumentError,
11
11
  'Invalid notation. Must be one of: [:flat, :dot, :subscript, :flat_array].'
12
12
  )
@@ -77,7 +77,7 @@ describe WebMock::Util::QueryMapper do
77
77
  expect(subject.to_query('a', {'key' => 'value'})).to eq('a[key]=value')
78
78
  end
79
79
  it 'should transform hash value with keys that are symbols' do
80
- expect(subject.to_query('a', {:key => 'value'})).to eq('a[key]=value')
80
+ expect(subject.to_query('a', {key: 'value'})).to eq('a[key]=value')
81
81
  end
82
82
  it 'should transform array value' do
83
83
  expect(subject.to_query('a', ['b', 'c'])).to eq('a[0]=b&a[1]=c')
@@ -206,7 +206,7 @@ describe WebMock::Util::URI do
206
206
  it "should successfully handle repeated paramters" do
207
207
  uri_string = "http://www.example.com:80/path?target=host1&target=host2"
208
208
  uri = WebMock::Util::URI.normalize_uri(uri_string)
209
- expect(WebMock::Util::QueryMapper.query_to_values(uri.query, :notation => WebMock::Config.instance.query_values_notation)).to eq([['target', 'host1'], ['target', 'host2']])
209
+ expect(WebMock::Util::QueryMapper.query_to_values(uri.query, notation: WebMock::Config.instance.query_values_notation)).to eq([['target', 'host1'], ['target', 'host2']])
210
210
  end
211
211
  end
212
212
  end
@@ -17,8 +17,8 @@ module HttpRequestTestHelper
17
17
  http.request(req, options[:body])
18
18
  }
19
19
  OpenStruct.new({
20
- :body => response.body,
21
- :headers => response,
22
- :status => response.code })
20
+ body: response.body,
21
+ headers: response,
22
+ status: response.code })
23
23
  end
24
24
  end
@@ -30,13 +30,13 @@ module SharedTest
30
30
 
31
31
  def test_verification_that_expected_request_occured
32
32
  http_request(:get, "http://www.example.com/")
33
- assert_requested(:get, "http://www.example.com", :times => 1)
33
+ assert_requested(:get, "http://www.example.com", times: 1)
34
34
  assert_requested(:get, "http://www.example.com")
35
35
  end
36
36
 
37
37
  def test_verification_that_expected_stub_occured
38
38
  http_request(:get, "http://www.example.com/")
39
- assert_requested(@stub_http, :times => 1)
39
+ assert_requested(@stub_http, times: 1)
40
40
  assert_requested(@stub_http)
41
41
  end
42
42
 
@@ -58,16 +58,16 @@ module SharedTest
58
58
 
59
59
  def test_verification_that_expected_request_occured_with_body_and_headers
60
60
  http_request(:get, "http://www.example.com/",
61
- :body => "abc", :headers => {'A' => 'a'})
61
+ body: "abc", headers: {'A' => 'a'})
62
62
  assert_requested(:get, "http://www.example.com",
63
- :body => "abc", :headers => {'A' => 'a'})
63
+ body: "abc", headers: {'A' => 'a'})
64
64
  end
65
65
 
66
66
  def test_verification_that_expected_request_occured_with_query_params
67
- stub_request(:any, "http://www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
67
+ stub_request(:any, "http://www.example.com").with(query: hash_including({"a" => ["b", "c"]}))
68
68
  http_request(:get, "http://www.example.com/?a[]=b&a[]=c&x=1")
69
69
  assert_requested(:get, "http://www.example.com",
70
- :query => hash_including({"a" => ["b", "c"]}))
70
+ query: hash_including({"a" => ["b", "c"]}))
71
71
  end
72
72
 
73
73
  def test_verification_that_non_expected_request_didnt_occur
@@ -31,9 +31,11 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'typhoeus', '>= 0.5.0' unless RUBY_PLATFORM =~ /java/
32
32
  s.add_development_dependency 'manticore', '>= 0.5.1' if RUBY_PLATFORM =~ /java/
33
33
  s.add_development_dependency 'excon', '>= 0.27.5'
34
- s.add_development_dependency 'minitest', '~> 5.0.0'
35
- s.add_development_dependency 'rdoc', '>3.5.0'
34
+ s.add_development_dependency 'minitest', '>= 5.0.0'
35
+ s.add_development_dependency 'test-unit', '>= 3.0.0'
36
+ s.add_development_dependency 'rdoc', '> 3.5.0'
36
37
  s.add_development_dependency 'rack'
38
+ s.add_development_dependency 'simplecov'
37
39
 
38
40
  s.files = `git ls-files`.split("\n")
39
41
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-20 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -182,16 +182,30 @@ dependencies:
182
182
  name: minitest
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - "~>"
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: 5.0.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - "~>"
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: 5.0.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: test-unit
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: 3.0.0
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 3.0.0
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: rdoc
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +234,20 @@ dependencies:
220
234
  - - ">="
221
235
  - !ruby/object:Gem::Version
222
236
  version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: simplecov
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
223
251
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP
224
252
  requests.
225
253
  email: