Permalink
Browse files

Renames WebMock#request to WebMock#a_request to avoid conflicts with …

…i.e rspec-rails. WebMock.request is still available.
  • Loading branch information...
1 parent aaf774b commit 6cb45ed177174ab59cc77497e68da0b36b477054 @bblimke committed Oct 6, 2010
Showing with 72 additions and 61 deletions.
  1. +9 −9 README.md
  2. +5 −1 lib/webmock/webmock.rb
  3. +58 −51 spec/webmock_spec.rb
View
@@ -353,19 +353,19 @@ You can also use WebMock outside a test framework:
### Different way of setting expectations in RSpec
- request(:post, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).should have_been_made.once
+ a_request(:post, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).should have_been_made.once
- request(:post, "www.something.com").should have_been_made.times(3)
+ a_request(:post, "www.something.com").should have_been_made.times(3)
- request(:any, "www.example.com").should_not have_been_made
+ a_request(:any, "www.example.com").should_not have_been_made
- request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
-
- request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made
-
- request(:post, "www.example.com").
+ a_request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
+
+ a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made
+
+ a_request(:post, "www.example.com").
with(:body => {"a" => ["b", "c"]}, :headers => 'Content-Type' => 'application/json').should have_been_made
-
+
## Clearing stubs and request history
If you want to reset all current stubs and history of requests use `WebMock.reset_webmock`
View
@@ -13,10 +13,14 @@ def stub_request(method, uri)
alias_method :stub_http_request, :stub_request
- def request(method, uri)
+ def a_request(method, uri)
RequestPattern.new(method, uri)
end
+ class << self
+ alias :request :a_request
+ end
+
def assert_requested(method, uri, options = {}, &block)
expected_times_executed = options.delete(:times) || 1
request = RequestPattern.new(method, uri, options).with(&block)
Oops, something went wrong.

2 comments on commit 6cb45ed

@brynary
brynary commented on 6cb45ed Oct 6, 2010

Just ran into this as I was trying WebMock for the first time -- fortunately it was the most recent commit. Any ETA on how long until a bug fix release can be done?

@bblimke
Owner

Good timing then :)

I want to reduce number of instance methods in WebMock module to a minimum to reduce the risk of other method name conflicts and then I'm going to release a new version, together with other new features.
I'm won't be able to look at it for the next couple of days, but I'm planning to release it early next week.

Please sign in to comment.