webmock 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +35 -0
- data/README.md +10 -24
- data/VERSION +1 -1
- data/lib/webmock.rb +4 -0
- data/lib/webmock/api.rb +1 -1
- data/lib/webmock/assertion_failure.rb +2 -4
- data/lib/webmock/cucumber.rb +8 -0
- data/lib/webmock/errors.rb +13 -1
- data/lib/webmock/http_lib_adapters/curb.rb +2 -2
- data/lib/webmock/http_lib_adapters/em_http_request.rb +31 -17
- data/lib/webmock/http_lib_adapters/httpclient.rb +3 -3
- data/lib/webmock/http_lib_adapters/net_http.rb +2 -2
- data/lib/webmock/http_lib_adapters/patron.rb +2 -2
- data/lib/webmock/request_execution_verifier.rb +18 -4
- data/lib/webmock/request_pattern.rb +1 -1
- data/lib/webmock/request_registry.rb +13 -28
- data/lib/webmock/request_signature.rb +15 -2
- data/lib/webmock/rspec.rb +32 -1
- data/lib/webmock/{adapters/rspec → rspec}/matchers.rb +4 -0
- data/lib/webmock/{adapters/rspec → rspec/matchers}/request_pattern_matcher.rb +0 -0
- data/lib/webmock/{adapters/rspec → rspec/matchers}/webmock_matcher.rb +0 -0
- data/lib/webmock/stub_registry.rb +43 -0
- data/lib/webmock/stub_request_snippet.rb +27 -0
- data/lib/webmock/test_unit.rb +20 -1
- data/lib/webmock/util/hash_counter.rb +9 -4
- data/lib/webmock/util/hash_keys_stringifier.rb +23 -0
- data/lib/webmock/webmock.rb +14 -4
- data/spec/curb_spec.rb +1 -1
- data/spec/curb_spec_helper.rb +0 -4
- data/spec/em_http_request_spec.rb +5 -0
- data/spec/em_http_request_spec_helper.rb +0 -4
- data/spec/errors_spec.rb +17 -0
- data/spec/httpclient_spec_helper.rb +0 -4
- data/spec/net_http_spec_helper.rb +2 -8
- data/spec/patron_spec_helper.rb +4 -11
- data/spec/request_execution_verifier_spec.rb +14 -4
- data/spec/request_registry_spec.rb +29 -80
- data/spec/request_signature_spec.rb +77 -3
- data/spec/spec_helper.rb +0 -18
- data/spec/stub_registry_spec.rb +86 -0
- data/spec/stub_request_snippet_spec.rb +47 -0
- data/spec/util/hash_counter_spec.rb +15 -0
- data/spec/util/hash_keys_stringifier_spec.rb +27 -0
- data/spec/webmock_shared.rb +63 -66
- data/test/test_helper.rb +5 -1
- data/test/test_webmock.rb +5 -2
- data/webmock.gemspec +17 -7
- metadata +19 -9
- data/lib/webmock/adapters/rspec.rb +0 -33
- data/lib/webmock/adapters/test_unit.rb +0 -19
data/test/test_helper.rb
CHANGED
@@ -11,6 +11,10 @@ class Test::Unit::TestCase
|
|
11
11
|
AssertionFailedError = Test::Unit::AssertionFailedError rescue MiniTest::Assertion
|
12
12
|
def assert_fail(message, &block)
|
13
13
|
e = assert_raise(AssertionFailedError, &block)
|
14
|
-
|
14
|
+
if message.is_a?(Regexp)
|
15
|
+
assert_match(message, e.message)
|
16
|
+
else
|
17
|
+
assert_equal(message, e.message)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
data/test/test_webmock.rb
CHANGED
@@ -46,7 +46,9 @@ class TestWebMock < Test::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_verification_that_expected_request_didnt_occur
|
49
|
-
|
49
|
+
expected_message = "The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times"
|
50
|
+
expected_message << "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
|
51
|
+
assert_fail(expected_message) do
|
50
52
|
assert_requested(:get, "http://www.example.com")
|
51
53
|
end
|
52
54
|
end
|
@@ -59,7 +61,8 @@ class TestWebMock < Test::Unit::TestCase
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def test_verification_that_non_expected_request_didnt_occur
|
62
|
-
|
64
|
+
expected_message = %r(The request GET http://www.example.com/ was expected to execute 0 times but it executed 1 time\n\nThe following requests were made:\n\nGET http://www.example.com/ with headers .+ was made 1 time\n\n============================================================)
|
65
|
+
assert_fail(expected_message) do
|
63
66
|
http_request(:get, "http://www.example.com/")
|
64
67
|
assert_not_requested(:get, "http://www.example.com")
|
65
68
|
end
|
data/webmock.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{webmock}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bartosz Blimke"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-12}
|
13
13
|
s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
|
14
14
|
s.email = %q{bartosz.blimke@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,15 +24,11 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/webmock.rb",
|
27
|
-
"lib/webmock/adapters/rspec.rb",
|
28
|
-
"lib/webmock/adapters/rspec/matchers.rb",
|
29
|
-
"lib/webmock/adapters/rspec/request_pattern_matcher.rb",
|
30
|
-
"lib/webmock/adapters/rspec/webmock_matcher.rb",
|
31
|
-
"lib/webmock/adapters/test_unit.rb",
|
32
27
|
"lib/webmock/api.rb",
|
33
28
|
"lib/webmock/assertion_failure.rb",
|
34
29
|
"lib/webmock/callback_registry.rb",
|
35
30
|
"lib/webmock/config.rb",
|
31
|
+
"lib/webmock/cucumber.rb",
|
36
32
|
"lib/webmock/deprecation.rb",
|
37
33
|
"lib/webmock/errors.rb",
|
38
34
|
"lib/webmock/http_lib_adapters/curb.rb",
|
@@ -49,8 +45,14 @@ Gem::Specification.new do |s|
|
|
49
45
|
"lib/webmock/response.rb",
|
50
46
|
"lib/webmock/responses_sequence.rb",
|
51
47
|
"lib/webmock/rspec.rb",
|
48
|
+
"lib/webmock/rspec/matchers.rb",
|
49
|
+
"lib/webmock/rspec/matchers/request_pattern_matcher.rb",
|
50
|
+
"lib/webmock/rspec/matchers/webmock_matcher.rb",
|
51
|
+
"lib/webmock/stub_registry.rb",
|
52
|
+
"lib/webmock/stub_request_snippet.rb",
|
52
53
|
"lib/webmock/test_unit.rb",
|
53
54
|
"lib/webmock/util/hash_counter.rb",
|
55
|
+
"lib/webmock/util/hash_keys_stringifier.rb",
|
54
56
|
"lib/webmock/util/headers.rb",
|
55
57
|
"lib/webmock/util/uri.rb",
|
56
58
|
"lib/webmock/webmock.rb",
|
@@ -58,6 +60,7 @@ Gem::Specification.new do |s|
|
|
58
60
|
"spec/curb_spec_helper.rb",
|
59
61
|
"spec/em_http_request_spec.rb",
|
60
62
|
"spec/em_http_request_spec_helper.rb",
|
63
|
+
"spec/errors_spec.rb",
|
61
64
|
"spec/example_curl_output.txt",
|
62
65
|
"spec/httpclient_spec.rb",
|
63
66
|
"spec/httpclient_spec_helper.rb",
|
@@ -74,7 +77,10 @@ Gem::Specification.new do |s|
|
|
74
77
|
"spec/request_stub_spec.rb",
|
75
78
|
"spec/response_spec.rb",
|
76
79
|
"spec/spec_helper.rb",
|
80
|
+
"spec/stub_registry_spec.rb",
|
81
|
+
"spec/stub_request_snippet_spec.rb",
|
77
82
|
"spec/util/hash_counter_spec.rb",
|
83
|
+
"spec/util/hash_keys_stringifier_spec.rb",
|
78
84
|
"spec/util/headers_spec.rb",
|
79
85
|
"spec/util/uri_spec.rb",
|
80
86
|
"spec/vendor/addressable/lib/addressable/uri.rb",
|
@@ -102,6 +108,7 @@ Gem::Specification.new do |s|
|
|
102
108
|
"spec/curb_spec_helper.rb",
|
103
109
|
"spec/em_http_request_spec.rb",
|
104
110
|
"spec/em_http_request_spec_helper.rb",
|
111
|
+
"spec/errors_spec.rb",
|
105
112
|
"spec/httpclient_spec.rb",
|
106
113
|
"spec/httpclient_spec_helper.rb",
|
107
114
|
"spec/net_http_spec.rb",
|
@@ -117,7 +124,10 @@ Gem::Specification.new do |s|
|
|
117
124
|
"spec/request_stub_spec.rb",
|
118
125
|
"spec/response_spec.rb",
|
119
126
|
"spec/spec_helper.rb",
|
127
|
+
"spec/stub_registry_spec.rb",
|
128
|
+
"spec/stub_request_snippet_spec.rb",
|
120
129
|
"spec/util/hash_counter_spec.rb",
|
130
|
+
"spec/util/hash_keys_stringifier_spec.rb",
|
121
131
|
"spec/util/headers_spec.rb",
|
122
132
|
"spec/util/uri_spec.rb",
|
123
133
|
"spec/vendor/addressable/lib/addressable/uri.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bartosz Blimke
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-12 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -148,15 +148,11 @@ files:
|
|
148
148
|
- Rakefile
|
149
149
|
- VERSION
|
150
150
|
- lib/webmock.rb
|
151
|
-
- lib/webmock/adapters/rspec.rb
|
152
|
-
- lib/webmock/adapters/rspec/matchers.rb
|
153
|
-
- lib/webmock/adapters/rspec/request_pattern_matcher.rb
|
154
|
-
- lib/webmock/adapters/rspec/webmock_matcher.rb
|
155
|
-
- lib/webmock/adapters/test_unit.rb
|
156
151
|
- lib/webmock/api.rb
|
157
152
|
- lib/webmock/assertion_failure.rb
|
158
153
|
- lib/webmock/callback_registry.rb
|
159
154
|
- lib/webmock/config.rb
|
155
|
+
- lib/webmock/cucumber.rb
|
160
156
|
- lib/webmock/deprecation.rb
|
161
157
|
- lib/webmock/errors.rb
|
162
158
|
- lib/webmock/http_lib_adapters/curb.rb
|
@@ -173,8 +169,14 @@ files:
|
|
173
169
|
- lib/webmock/response.rb
|
174
170
|
- lib/webmock/responses_sequence.rb
|
175
171
|
- lib/webmock/rspec.rb
|
172
|
+
- lib/webmock/rspec/matchers.rb
|
173
|
+
- lib/webmock/rspec/matchers/request_pattern_matcher.rb
|
174
|
+
- lib/webmock/rspec/matchers/webmock_matcher.rb
|
175
|
+
- lib/webmock/stub_registry.rb
|
176
|
+
- lib/webmock/stub_request_snippet.rb
|
176
177
|
- lib/webmock/test_unit.rb
|
177
178
|
- lib/webmock/util/hash_counter.rb
|
179
|
+
- lib/webmock/util/hash_keys_stringifier.rb
|
178
180
|
- lib/webmock/util/headers.rb
|
179
181
|
- lib/webmock/util/uri.rb
|
180
182
|
- lib/webmock/webmock.rb
|
@@ -182,6 +184,7 @@ files:
|
|
182
184
|
- spec/curb_spec_helper.rb
|
183
185
|
- spec/em_http_request_spec.rb
|
184
186
|
- spec/em_http_request_spec_helper.rb
|
187
|
+
- spec/errors_spec.rb
|
185
188
|
- spec/example_curl_output.txt
|
186
189
|
- spec/httpclient_spec.rb
|
187
190
|
- spec/httpclient_spec_helper.rb
|
@@ -198,7 +201,10 @@ files:
|
|
198
201
|
- spec/request_stub_spec.rb
|
199
202
|
- spec/response_spec.rb
|
200
203
|
- spec/spec_helper.rb
|
204
|
+
- spec/stub_registry_spec.rb
|
205
|
+
- spec/stub_request_snippet_spec.rb
|
201
206
|
- spec/util/hash_counter_spec.rb
|
207
|
+
- spec/util/hash_keys_stringifier_spec.rb
|
202
208
|
- spec/util/headers_spec.rb
|
203
209
|
- spec/util/uri_spec.rb
|
204
210
|
- spec/vendor/addressable/lib/addressable/uri.rb
|
@@ -254,6 +260,7 @@ test_files:
|
|
254
260
|
- spec/curb_spec_helper.rb
|
255
261
|
- spec/em_http_request_spec.rb
|
256
262
|
- spec/em_http_request_spec_helper.rb
|
263
|
+
- spec/errors_spec.rb
|
257
264
|
- spec/httpclient_spec.rb
|
258
265
|
- spec/httpclient_spec_helper.rb
|
259
266
|
- spec/net_http_spec.rb
|
@@ -269,7 +276,10 @@ test_files:
|
|
269
276
|
- spec/request_stub_spec.rb
|
270
277
|
- spec/response_spec.rb
|
271
278
|
- spec/spec_helper.rb
|
279
|
+
- spec/stub_registry_spec.rb
|
280
|
+
- spec/stub_request_snippet_spec.rb
|
272
281
|
- spec/util/hash_counter_spec.rb
|
282
|
+
- spec/util/hash_keys_stringifier_spec.rb
|
273
283
|
- spec/util/headers_spec.rb
|
274
284
|
- spec/util/uri_spec.rb
|
275
285
|
- spec/vendor/addressable/lib/addressable/uri.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'webmock'
|
2
|
-
|
3
|
-
# RSpec 1.x and 2.x compatibility
|
4
|
-
if defined?(RSpec)
|
5
|
-
RSPEC_NAMESPACE = RSPEC_CONFIGURER = RSpec
|
6
|
-
elsif defined?(Spec)
|
7
|
-
RSPEC_NAMESPACE = Spec
|
8
|
-
RSPEC_CONFIGURER = Spec::Runner
|
9
|
-
else
|
10
|
-
begin
|
11
|
-
require 'rspec'
|
12
|
-
RSPEC_NAMESPACE = RSPEC_CONFIGURER = RSpec
|
13
|
-
rescue LoadError
|
14
|
-
require 'spec'
|
15
|
-
RSPEC_NAMESPACE = Spec
|
16
|
-
RSPEC_CONFIGURER = Spec::Runner
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'webmock/adapters/rspec/request_pattern_matcher'
|
21
|
-
require 'webmock/adapters/rspec/webmock_matcher'
|
22
|
-
require 'webmock/adapters/rspec/matchers'
|
23
|
-
|
24
|
-
RSPEC_CONFIGURER.configure { |config|
|
25
|
-
|
26
|
-
config.include WebMock::Matchers
|
27
|
-
|
28
|
-
config.before :each do
|
29
|
-
WebMock.reset_webmock
|
30
|
-
end
|
31
|
-
}
|
32
|
-
|
33
|
-
WebMock::AssertionFailure.error_class = RSPEC_NAMESPACE::Expectations::ExpectationNotMetError
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'webmock'
|
3
|
-
|
4
|
-
class Test::Unit::TestCase
|
5
|
-
alias setup_without_webmock setup
|
6
|
-
def setup
|
7
|
-
WebMock.reset_webmock
|
8
|
-
@original_allow_net_connect = WebMock.net_connect_allowed?
|
9
|
-
WebMock.disable_net_connect!
|
10
|
-
end
|
11
|
-
|
12
|
-
alias teardown_without_webmock teardown
|
13
|
-
def teardown
|
14
|
-
@original_allow_net_connect ? WebMock.allow_net_connect! : WebMock.disable_net_connect!
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
WebMock::AssertionFailure.error_class = Test::Unit::AssertionFailedError rescue MiniTest::Assertion # ruby1.9 compat
|