webmock 1.7.10 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.travis.yml +2 -2
  2. data/CHANGELOG.md +98 -24
  3. data/Gemfile +2 -3
  4. data/README.md +45 -4
  5. data/Rakefile +2 -2
  6. data/lib/webmock.rb +3 -0
  7. data/lib/webmock/api.rb +34 -6
  8. data/lib/webmock/http_lib_adapters/curb_adapter.rb +4 -41
  9. data/lib/webmock/http_lib_adapters/em_http_request/em_http_request_1_x.rb +1 -1
  10. data/lib/webmock/http_lib_adapters/excon_adapter.rb +94 -0
  11. data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +31 -4
  12. data/lib/webmock/http_lib_adapters/net_http.rb +2 -0
  13. data/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +4 -3
  14. data/lib/webmock/matchers/hash_including_matcher.rb +25 -0
  15. data/lib/webmock/rack_response.rb +8 -1
  16. data/lib/webmock/request_pattern.rb +108 -77
  17. data/lib/webmock/request_signature.rb +1 -0
  18. data/lib/webmock/stub_registry.rb +9 -8
  19. data/lib/webmock/version.rb +1 -1
  20. data/lib/webmock/webmock.rb +5 -2
  21. data/minitest/webmock_spec.rb +22 -2
  22. data/spec/acceptance/curb/curb_spec_helper.rb +12 -2
  23. data/spec/acceptance/em_http_request/em_http_request_spec.rb +42 -33
  24. data/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +4 -2
  25. data/spec/acceptance/excon/excon_spec.rb +15 -0
  26. data/spec/acceptance/excon/excon_spec_helper.rb +37 -0
  27. data/spec/acceptance/net_http/net_http_spec.rb +7 -0
  28. data/spec/acceptance/net_http/net_http_spec_helper.rb +3 -1
  29. data/spec/acceptance/patron/patron_spec.rb +12 -3
  30. data/spec/acceptance/patron/patron_spec_helper.rb +2 -2
  31. data/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +3 -3
  32. data/spec/acceptance/shared/callbacks.rb +22 -6
  33. data/spec/acceptance/shared/complex_cross_concern_behaviors.rb +21 -0
  34. data/spec/acceptance/shared/enabling_and_disabling_webmock.rb +10 -11
  35. data/spec/acceptance/shared/precedence_of_stubs.rb +1 -1
  36. data/spec/acceptance/shared/request_expectations.rb +49 -3
  37. data/spec/acceptance/shared/returning_declared_responses.rb +9 -21
  38. data/spec/acceptance/shared/stubbing_requests.rb +80 -4
  39. data/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +1 -1
  40. data/spec/acceptance/webmock_shared.rb +11 -8
  41. data/spec/spec_helper.rb +3 -3
  42. data/spec/support/my_rack_app.rb +25 -1
  43. data/spec/support/webmock_server.rb +9 -6
  44. data/spec/unit/rack_response_spec.rb +18 -0
  45. data/spec/unit/request_pattern_spec.rb +205 -96
  46. data/spec/unit/request_signature_spec.rb +36 -34
  47. data/spec/unit/util/uri_spec.rb +14 -2
  48. data/test/shared_test.rb +31 -2
  49. data/webmock.gemspec +9 -7
  50. metadata +86 -73
@@ -3,7 +3,7 @@ rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
5
  - ree
6
- - jruby
6
+ - jruby-19mode
7
7
 
8
8
 
9
- script: "bundle exec rake JRUBY_OPTS='–server -Dnative.enabled=true' && rake em_http_request_1_x_spec"
9
+ script: "bundle exec rake && rake em_http_request_0_x_spec"
@@ -1,5 +1,79 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.0
4
+
5
+ * Matching request body against partial hash.
6
+
7
+ stub_http_request(:post, "www.example.com").
8
+ with(:body => hash_including({:data => {:a => '1', :b => 'five'}}))
9
+
10
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
11
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
12
+
13
+ request(:post, "www.example.com").
14
+ with(:body => hash_including({:data => {:a => '1', :b => 'five'}}),
15
+ :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
16
+
17
+ Thanks to [Marnen Laibow-Koser](https://github.com/marnen) for help with this solution
18
+
19
+ * Matching request query params against partial hash.
20
+
21
+ stub_http_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
22
+
23
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
24
+
25
+ request(:get, "www.example.com").
26
+ with(:query => hash_including({"a" => ["b", "c"]})).should have_been_made # ===> Success
27
+
28
+ * Added support for Excon.
29
+
30
+ Thanks to [Dimitrij Denissenko](https://github.com/dim)
31
+
32
+ * Added support for setting expectations on the request stub with `assert_requested`
33
+
34
+ stub_get = stub_request(:get, "www.example.com")
35
+ stub_post = stub_request(:post, "www.example.com")
36
+
37
+ Net::HTTP.get('www.example.com', '/')
38
+
39
+ assert_requested(stub_get)
40
+ assert_not_requested(stub_post)
41
+
42
+ Thanks to [Nicolas Fouché](https://github.com/nfo)
43
+
44
+ * `WebMock.disable_net_connect!` accepts `RegExp` as `:allow` parameter
45
+
46
+ Thanks to [Frank Schumacher](https://github.com/thenoseman)
47
+
48
+ * Ensure multiple values for the same header can be recorded and played back
49
+
50
+ Thanks to [Myron Marston](https://github.com/myronmarston)
51
+
52
+ * Updated dependency on Addressable to version >= 2.2.7 to handle nested hash query values. I.e. `?one[two][three][]=four&one[two][three][]=five`
53
+
54
+ * Fixed compatibility with Curb >= 0.7.16 This breaks compatibility with Curb < 0.7.16
55
+
56
+ * Fix #to_rack to handle non-array response bodies.
57
+
58
+ Thanks to [Tammer Saleh](https://github.com/tsaleh)
59
+
60
+ * Added `read_timeout` accessor to StubSocket which fixes compatibility with aws-sdk
61
+
62
+ Thanks to [Lin Jen-Shin](https://github.com/godfat)
63
+
64
+ * Fix warning "instance variable @query_params not initialized"
65
+
66
+ Thanks to [Joe Van Dyk](https://github.com/joevandyk)
67
+
68
+ * Using bytesize of message instead of its length for content-length header in em-http-request adapter.
69
+ This fixes a problem with messages getting truncated in Ruby >= 1.9
70
+
71
+ Thanks to [Mark Abramov](https://github.com/markiz)
72
+
73
+ * Fixed problem with body params being matched even if params were different.
74
+
75
+ Thanks to [Evgeniy Dolzhenko](https://github.com/dolzenko) for reporting this issue.
76
+
3
77
  ## 1.7.10
4
78
 
5
79
  * Yanked 1.7.9 and rebuilt gem on 1.8.7 to deal with syck/psych incompatibilties in gemspec.
@@ -297,11 +371,11 @@ josevalim:
297
371
 
298
372
  This feature was available before only for localhost with `:allow_localhost => true`
299
373
 
300
- WebMock.disable_net_connect!(:allow => "www.example.org")
374
+ WebMock.disable_net_connect!(:allow => "www.example.org")
301
375
 
302
- Net::HTTP.get('www.something.com', '/') # ===> Failure
376
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
303
377
 
304
- Net::HTTP.get('www.example.org', '/') # ===> Allowed.
378
+ Net::HTTP.get('www.example.org', '/') # ===> Allowed.
305
379
 
306
380
  * Fixed Net::HTTP adapter so that it preserves the original behavior of Net::HTTP.
307
381
 
@@ -333,51 +407,51 @@ josevalim:
333
407
 
334
408
  * Matching query params using a hash
335
409
 
336
- stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
410
+ stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
337
411
 
338
- RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
412
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
339
413
 
340
- request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made # ===> Success
414
+ request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made # ===> Success
341
415
 
342
416
  * Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
343
417
 
344
418
  (Thanks to Steve Tooke for the idea and a solution for url-encoded bodies)
345
419
 
346
- stub_http_request(:post, "www.example.com").
347
- with(:body => {:data => {:a => '1', :b => 'five'}})
420
+ stub_http_request(:post, "www.example.com").
421
+ with(:body => {:data => {:a => '1', :b => 'five'}})
348
422
 
349
- RestClient.post('www.example.com', "data[a]=1&data[b]=five",
350
- :content_type => 'application/x-www-form-urlencoded') # ===> Success
423
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
424
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
351
425
 
352
- RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
353
- :content_type => 'application/json') # ===> Success
426
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
427
+ :content_type => 'application/json') # ===> Success
354
428
 
355
- RestClient.post('www.example.com', '<data a="1" b="five" />',
356
- :content_type => 'application/xml' ) # ===> Success
429
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
430
+ :content_type => 'application/xml' ) # ===> Success
357
431
 
358
- request(:post, "www.example.com").
432
+ request(:post, "www.example.com").
359
433
  with(:body => {:data => {:a => '1', :b => 'five'}},
360
- :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
434
+ :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
361
435
 
362
436
  * Request callbacks (Thanks to Myron Marston for all suggestions)
363
437
 
364
438
  WebMock can now invoke callbacks for stubbed or real requests:
365
439
 
366
- WebMock.after_request do |request_signature, response|
367
- puts "Request #{request_signature} was made and #{response} was returned"
368
- end
440
+ WebMock.after_request do |request_signature, response|
441
+ puts "Request #{request_signature} was made and #{response} was returned"
442
+ end
369
443
 
370
444
  invoke callbacks for real requests only and except requests made with Patron client
371
445
 
372
- WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
373
- puts "Request #{request_signature} was made and #{response} was returned"
374
- end
446
+ WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
447
+ puts "Request #{request_signature} was made and #{response} was returned"
448
+ end
375
449
 
376
450
  * `to_raise()` now accepts an exception instance or a string as argument in addition to an exception class
377
451
 
378
- stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
452
+ stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
379
453
 
380
- stub_request(:any, 'www.example.net').to_raise("some error")
454
+ stub_request(:any, 'www.example.net').to_raise("some error")
381
455
 
382
456
  * Matching requests based on a URI is 30% faster
383
457
 
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
1
  source 'http://rubygems.org/'
2
2
 
3
3
  gemspec
4
- if ENV["EM_HTTP_REQUEST_1_X"]
5
- gem 'em-http-request', '>= 1.0.0'
6
- gem 'em-synchrony', '>= 1.0.0'
4
+ if ENV["EM_HTTP_REQUEST_0_X"]
5
+ gem 'em-http-request', '~> 0.3.0'
7
6
  end
8
7
 
9
8
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- WebMock [![Build Status](https://secure.travis-ci.org/bblimke/webmock.png)](http://travis-ci.org/bblimke/webmock)
1
+ WebMock [![Build Status](https://secure.travis-ci.org/bblimke/webmock.png)](http://travis-ci.org/bblimke/webmock) [![Dependency Status](https://gemnasium.com/bblimke/webmock.png)](http://gemnasium.com/bblimke/webmock)
2
2
  =======
3
3
 
4
4
  Library for stubbing and setting expectations on HTTP requests in Ruby.
@@ -24,6 +24,7 @@ Supported HTTP libraries
24
24
  * EM-HTTP-Request
25
25
  * Curb (currently only Curb::Easy)
26
26
  * Typhoeus (currently only Typhoeus::Hydra)
27
+ * Excon
27
28
 
28
29
  Supported Ruby Interpreters
29
30
  ---------------------------
@@ -32,13 +33,13 @@ Supported Ruby Interpreters
32
33
  * MRI 1.8.7
33
34
  * MRI 1.9.1
34
35
  * MRI 1.9.2
35
- * MRI 1.9.3-preview1
36
+ * MRI 1.9.3
36
37
  * REE 1.8.7
37
38
  * JRuby
38
39
 
39
40
  ##Installation
40
41
 
41
- gem install webmock --source http://gemcutter.org
42
+ gem install webmock
42
43
 
43
44
  ### or to install the latest development version from github master
44
45
 
@@ -125,6 +126,14 @@ You can also use WebMock outside a test framework:
125
126
  RestClient.post('www.example.com', '<data a="1" b="five" />',
126
127
  :content_type => 'application/xml' ) # ===> Success
127
128
 
129
+ ### Matching request body against partial hash.
130
+
131
+ stub_http_request(:post, "www.example.com").
132
+ with(:body => hash_including({:data => {:a => '1', :b => 'five'}}))
133
+
134
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five&x=1",
135
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
136
+
128
137
  ### Matching custom request headers
129
138
 
130
139
  stub_request(:any, "www.example.com").with(:headers=>{ 'Header-Name' => 'Header-Value' })
@@ -172,6 +181,12 @@ You can also use WebMock outside a test framework:
172
181
 
173
182
  RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
174
183
 
184
+ ### Matching partial query params using hash
185
+
186
+ stub_http_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
187
+
188
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c&x=1") # ===> Success
189
+
175
190
  ### Stubbing with custom response
176
191
 
177
192
  stub_request(:any, "www.example.com").to_return(:body => "abc", :status => 200, :headers => { 'Content-Length' => 3 } )
@@ -319,7 +334,7 @@ You can also use WebMock outside a test framework:
319
334
 
320
335
  Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
321
336
 
322
- ### External requests can be disabled while allowing any hostname or port
337
+ ### External requests can be disabled while allowing any hostname or port or parts thereof
323
338
 
324
339
  WebMock.disable_net_connect!(:allow => "www.example.org:8080")
325
340
 
@@ -329,6 +344,10 @@ You can also use WebMock outside a test framework:
329
344
 
330
345
  RestClient.get('www.example.org:8080', '/') # ===> Allowed
331
346
 
347
+ WebMock.disable_net_connect!(:allow => /ample.org/)
348
+
349
+ RestClient.get('www.example.org', '/') # ===> Allowed
350
+
332
351
  ## Connecting on Net::HTTP.start
333
352
 
334
353
  HTTP protocol has 3 steps: connect, request and response (or 4 with close). Most Ruby HTTP client libraries
@@ -377,6 +396,16 @@ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
377
396
 
378
397
  assert_requested :get, "http://www.example.com" # ===> Success
379
398
 
399
+ ### Setting expectations in Test::Unit on the stub
400
+
401
+ stub_get = stub_request(:get, "www.example.com")
402
+ stub_post = stub_request(:post, "www.example.com")
403
+
404
+ Net::HTTP.get('www.example.com', '/')
405
+
406
+ assert_requested(stub_get)
407
+ assert_not_requested(stub_post)
408
+
380
409
 
381
410
  ### Setting expectations in RSpec on `WebMock` module
382
411
  This style is borrowed from [fakeweb-matcher](http://github.com/freelancing-god/fakeweb-matcher)
@@ -391,6 +420,8 @@ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
391
420
 
392
421
  WebMock.should have_requested(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
393
422
 
423
+ WebMock.should have_requested(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
424
+
394
425
  WebMock.should have_requested(:get, "www.example.com").
395
426
  with(:body => {"a" => ["b", "c"]}, :headers => {'Content-Type' => 'application/json'})
396
427
 
@@ -406,6 +437,8 @@ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
406
437
 
407
438
  a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made
408
439
 
440
+ a_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]})).should have_been_made
441
+
409
442
  a_request(:post, "www.example.com").
410
443
  with(:body => {"a" => ["b", "c"]}, :headers => {'Content-Type' => 'application/json'}).should have_been_made
411
444
 
@@ -654,6 +687,14 @@ People who submitted patches and new features or suggested improvements. Many th
654
687
  * Eugene Pimenov
655
688
  * Albert Llop
656
689
  * Christopher Pickslay
690
+ * Tammer Saleh
691
+ * Nicolas Fouché
692
+ * Joe Van Dyk
693
+ * Mark Abramov
694
+ * Frank Schumacher
695
+ * Dimitrij Denissenko
696
+ * Marnen Laibow-Koser
697
+ * Evgeniy Dolzhenko
657
698
 
658
699
  For a full list of contributors you can visit the
659
700
  [contributors](https://github.com/bblimke/webmock/contributors) page.
data/Rakefile CHANGED
@@ -26,8 +26,8 @@ RSpec::Core::RakeTask.new(:spec_http_without_webmock) do |t|
26
26
  end
27
27
 
28
28
 
29
- task :em_http_request_1_x_spec do
30
- sh "EM_HTTP_REQUEST_1_X=true bundle install && bundle exec rspec spec/acceptance/em_http_request/em_http_request_spec.rb" if RUBY_VERSION >= "1.9.2"
29
+ task :em_http_request_0_x_spec do
30
+ sh "EM_HTTP_REQUEST_0_X=true bundle install && bundle exec rspec spec/acceptance/em_http_request/em_http_request_spec.rb" if RUBY_VERSION <= "1.8.7"
31
31
  end
32
32
 
33
33
  require 'rake/testtask'
@@ -14,6 +14,7 @@ require 'webmock/http_lib_adapters/patron_adapter'
14
14
  require 'webmock/http_lib_adapters/curb_adapter'
15
15
  require 'webmock/http_lib_adapters/em_http_request_adapter'
16
16
  require 'webmock/http_lib_adapters/typhoeus_hydra_adapter'
17
+ require 'webmock/http_lib_adapters/excon_adapter'
17
18
 
18
19
  require 'webmock/errors'
19
20
 
@@ -23,6 +24,8 @@ require 'webmock/util/hash_counter'
23
24
  require 'webmock/util/hash_keys_stringifier'
24
25
  require 'webmock/util/json'
25
26
 
27
+ require 'webmock/matchers/hash_including_matcher'
28
+
26
29
  require 'webmock/request_pattern'
27
30
  require 'webmock/request_signature'
28
31
  require 'webmock/responses_sequence'
@@ -17,17 +17,45 @@ module WebMock
17
17
  alias :request :a_request
18
18
  end
19
19
 
20
- def assert_requested(method, uri, options = {}, &block)
21
- expected_times_executed = options.delete(:times) || 1
22
- request = WebMock::RequestPattern.new(method, uri, options).with(&block)
23
- verifier = WebMock::RequestExecutionVerifier.new(request, expected_times_executed)
20
+
21
+ def assert_requested(*args, &block)
22
+ if not args[0].is_a?(WebMock::RequestStub)
23
+ args = convert_uri_method_and_options_to_request_and_options(*args, &block)
24
+ end
25
+ assert_request_requested(*args, &block)
26
+ end
27
+
28
+ def assert_not_requested(*args, &block)
29
+ if not args[0].is_a?(WebMock::RequestStub)
30
+ args = convert_uri_method_and_options_to_request_and_options(*args, &block)
31
+ end
32
+ assert_request_not_requested(*args, &block)
33
+ end
34
+
35
+ def hash_including(expected)
36
+ if defined?(::RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher)
37
+ RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher.new(expected)
38
+ else
39
+ WebMock::Matchers::HashIncludingMatcher.new(expected)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def convert_uri_method_and_options_to_request_and_options(*args, &block)
46
+ request = WebMock::RequestPattern.new(*args).with(&block)
47
+ [request, args[2] || {}]
48
+ end
49
+
50
+ def assert_request_requested(request, options = {})
51
+ verifier = WebMock::RequestExecutionVerifier.new(request, options.delete(:times) || 1)
24
52
  WebMock::AssertionFailure.failure(verifier.failure_message) unless verifier.matches?
25
53
  end
26
54
 
27
- def assert_not_requested(method, uri, options = {}, &block)
28
- request = WebMock::RequestPattern.new(method, uri, options).with(&block)
55
+ def assert_request_not_requested(request, options = {})
29
56
  verifier = WebMock::RequestExecutionVerifier.new(request, options.delete(:times))
30
57
  WebMock::AssertionFailure.failure(verifier.negative_failure_message) unless verifier.does_not_match?
31
58
  end
59
+
32
60
  end
33
61
  end
@@ -53,6 +53,7 @@ if defined?(Curl)
53
53
  module Curl
54
54
  class WebMockCurlEasy < Curl::Easy
55
55
  def curb_or_webmock
56
+
56
57
  request_signature = build_request_signature
57
58
  WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
58
59
 
@@ -169,9 +170,7 @@ if defined?(Curl)
169
170
 
170
171
  def http_with_webmock(method)
171
172
  @webmock_method = method
172
- curb_or_webmock do
173
173
  http_without_webmock(method)
174
- end
175
174
  end
176
175
  alias_method :http_without_webmock, :http
177
176
  alias_method :http, :http_with_webmock
@@ -179,9 +178,7 @@ if defined?(Curl)
179
178
  %w[ get head delete ].each do |verb|
180
179
  define_method "http_#{verb}_with_webmock" do
181
180
  @webmock_method = verb
182
- curb_or_webmock do
183
- send( "http_#{verb}_without_webmock" )
184
- end
181
+ send( "http_#{verb}_without_webmock" )
185
182
  end
186
183
 
187
184
  alias_method "http_#{verb}_without_webmock", "http_#{verb}"
@@ -191,9 +188,7 @@ if defined?(Curl)
191
188
  def http_put_with_webmock data = nil
192
189
  @webmock_method = :put
193
190
  @put_data = data if data
194
- curb_or_webmock do
195
- http_put_without_webmock(data)
196
- end
191
+ http_put_without_webmock(data)
197
192
  end
198
193
  alias_method :http_put_without_webmock, :http_put
199
194
  alias_method :http_put, :http_put_with_webmock
@@ -201,9 +196,7 @@ if defined?(Curl)
201
196
  def http_post_with_webmock *data
202
197
  @webmock_method = :post
203
198
  @post_body = data.join('&') if data && !data.empty?
204
- curb_or_webmock do
205
- http_post_without_webmock(*data)
206
- end
199
+ http_post_without_webmock(*data)
207
200
  end
208
201
  alias_method :http_post_without_webmock, :http_post
209
202
  alias_method :http_post, :http_post_with_webmock
@@ -287,36 +280,6 @@ if defined?(Curl)
287
280
  alias_method "on_#{callback}_without_webmock", "on_#{callback}"
288
281
  alias_method "on_#{callback}", "on_#{callback}_with_webmock"
289
282
  end
290
-
291
- %w[ http_get http_head http_delete perform ].each do |method|
292
- class_eval <<-METHOD, __FILE__, __LINE__
293
- def self.#{method}(url, &block)
294
- c = new
295
- c.url = url
296
- block.call(c) if block
297
- c.send("#{method}")
298
- c
299
- end
300
- METHOD
301
- end
302
-
303
- class_eval <<-METHOD, __FILE__, __LINE__
304
- def self.http_put(url, data, &block)
305
- c = new
306
- c.url = url
307
- block.call(c) if block
308
- c.send(:http_put, data)
309
- c
310
- end
311
-
312
- def self.http_post(url, *data, &block)
313
- c = new
314
- c.url = url
315
- block.call(c) if block
316
- c.send(:http_post, *data)
317
- c
318
- end
319
- METHOD
320
283
  end
321
284
  end
322
285
  end