Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Document setting up a WebMock development environment

 - Describe how to create a gemset for each supported Ruby version

 - A rake task to run specs via RVM's exec command

 - Add a link to the contributors page

Running `rake spec:rubies` will use RVM's exec to run specs against MRI
1.8.6, 1.8.7 and 1.9.2, Ruby Enterprise Edition and jRuby.
  • Loading branch information...
commit 221e8cd5d96c99174a510c6ff4cce9e216d65c42 1 parent 7c2b9cf
@jcf jcf authored
Showing with 234 additions and 175 deletions.
  1. +223 −175 README.md
  2. +11 −0 Rakefile
View
398 README.md
@@ -31,36 +31,36 @@ Supported HTTP libraries
##Installation
- gem install webmock --source http://gemcutter.org
+ gem install webmock --source http://gemcutter.org
### or to install the latest development version from github master
- git clone http://github.com/bblimke/webmock.git
- cd webmock
- rake install
+ git clone http://github.com/bblimke/webmock.git
+ cd webmock
+ rake install
-### Test::Unit
+### Test::Unit
Add the following code to `test/test_helper.rb`
- require 'webmock/test_unit'
+ require 'webmock/test_unit'
### RSpec
-
+
Add the following code to `spec/spec_helper`:
- require 'webmock/rspec'
+ require 'webmock/rspec'
### Cucumber
Add the following code to `features/support/env.rb`
- require 'webmock/cucumber'
+ require 'webmock/cucumber'
You can also use WebMock outside a test framework:
- require 'webmock'
- include WebMock::API
+ require 'webmock'
+ include WebMock::API
## Examples
@@ -71,72 +71,72 @@ You can also use WebMock outside a test framework:
### Stubbed request based on uri only and with the default response
- stub_request(:any, "www.example.com")
+ stub_request(:any, "www.example.com")
- Net::HTTP.get("www.example.com", "/") # ===> Success
+ Net::HTTP.get("www.example.com", "/") # ===> Success
### Stubbing requests based on method, uri, body and headers
- stub_request(:post, "www.example.com").with(:body => "abc", :headers => { 'Content-Length' => 3 })
+ stub_request(:post, "www.example.com").with(:body => "abc", :headers => { 'Content-Length' => 3 })
- uri = URI.parse("http://www.example.com/")
+ uri = URI.parse("http://www.example.com/")
req = Net::HTTP::Post.new(uri.path)
- req['Content-Length'] = 3
+ req['Content-Length'] = 3
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req, "abc")
} # ===> Success
### Matching request body and headers against regular expressions
- stub_request(:post, "www.example.com").
- with(:body => /^.*world$/, :headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
+ stub_request(:post, "www.example.com").
+ with(:body => /^.*world$/, :headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
- uri = URI.parse('http://www.example.com/')
+ uri = URI.parse('http://www.example.com/')
req = Net::HTTP::Post.new(uri.path)
- req['Content-Type'] = 'image/png'
+ req['Content-Type'] = 'image/png'
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req, 'hello world')
} # ===> Success
-
+
### Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
- stub_http_request(:post, "www.example.com").
- with(:body => {:data => {:a => '1', :b => 'five'}})
+ stub_http_request(:post, "www.example.com").
+ with(:body => {:data => {:a => '1', :b => 'five'}})
+
+ RestClient.post('www.example.com', "data[a]=1&data[b]=five",
+ :content_type => 'application/x-www-form-urlencoded') # ===> Success
- RestClient.post('www.example.com', "data[a]=1&data[b]=five",
- :content_type => 'application/x-www-form-urlencoded') # ===> Success
-
- RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
- :content_type => 'application/json') # ===> Success
-
- RestClient.post('www.example.com', '<data a="1" b="five" />',
- :content_type => 'application/xml' ) # ===> Success
+ RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
+ :content_type => 'application/json') # ===> Success
+
+ RestClient.post('www.example.com', '<data a="1" b="five" />',
+ :content_type => 'application/xml' ) # ===> Success
### Matching custom request headers
stub_request(:any, "www.example.com").with(:headers=>{ 'Header-Name' => 'Header-Value' })
- uri = URI.parse('http://www.example.com/')
+ uri = URI.parse('http://www.example.com/')
req = Net::HTTP::Post.new(uri.path)
- req['Header-Name'] = 'Header-Value'
+ req['Header-Name'] = 'Header-Value'
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req, 'abc')
} # ===> Success
### Matching multiple headers with the same name
- stub_http_request(:get, 'www.example.com').with(:headers => {'Accept' => ['image/jpeg', 'image/png'] })
-
- req = Net::HTTP::Get.new("/")
- req['Accept'] = ['image/png']
- req.add_field('Accept', 'image/jpeg')
- Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
+ stub_http_request(:get, 'www.example.com').with(:headers => {'Accept' => ['image/jpeg', 'image/png'] })
+
+ req = Net::HTTP::Get.new("/")
+ req['Accept'] = ['image/png']
+ req.add_field('Accept', 'image/jpeg')
+ Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
### Matching requests against provided block
- stub_request(:post, "www.example.com").with { |request| request.body == "abc" }
- RestClient.post('www.example.com', 'abc') # ===> Success
-
+ stub_request(:post, "www.example.com").with { |request| request.body == "abc" }
+ RestClient.post('www.example.com', 'abc') # ===> Success
+
### Request with basic authentication
stub_request(:get, "user:pass@www.example.com")
@@ -149,49 +149,49 @@ You can also use WebMock outside a test framework:
### Matching uris using regular expressions
- stub_request(:any, /.*example.*/)
+ stub_request(:any, /.*example.*/)
- Net::HTTP.get('www.example.com', '/') # ===> Success
-
-### Matching query params using hash
+ Net::HTTP.get('www.example.com', '/') # ===> Success
+
+### Matching query params using hash
+
+ stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
+
+ RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
- stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
-
- RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
-
### Stubbing with custom response
- stub_request(:any, "www.example.com").to_return(:body => "abc", :status => 200, :headers => { 'Content-Length' => 3 } )
-
- Net::HTTP.get("www.example.com", '/') # ===> "abc"
+ stub_request(:any, "www.example.com").to_return(:body => "abc", :status => 200, :headers => { 'Content-Length' => 3 } )
+
+ Net::HTTP.get("www.example.com", '/') # ===> "abc"
### Response with body specified as IO object
- File.open('/tmp/response_body.txt', 'w') { |f| f.puts 'abc' }
+ File.open('/tmp/response_body.txt', 'w') { |f| f.puts 'abc' }
+
+ stub_request(:any, "www.example.com").to_return(:body => File.new('/tmp/response_body.txt'), :status => 200)
- stub_request(:any, "www.example.com").to_return(:body => File.new('/tmp/response_body.txt'), :status => 200)
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
-
### Response with custom status message
- stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
+ stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
+
+ req = Net::HTTP::Get.new("/")
+ Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
- req = Net::HTTP::Get.new("/")
- Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
-
### Replaying raw responses recorded with `curl -is`
- `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
- raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
+ `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
+ raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
from file
- stub_request(:get, "www.example.com").to_return(raw_response_file)
+ stub_request(:get, "www.example.com").to_return(raw_response_file)
or string
- stub_request(:get, "www.example.com").to_return(raw_response_file.read)
+ stub_request(:get, "www.example.com").to_return(raw_response_file.read)
### Responses dynamically evaluated from block
@@ -205,7 +205,7 @@ You can also use WebMock outside a test framework:
stub_request(:any, 'www.example.net').
to_return(lambda { |request| {:body => request.body} })
- RestClient.post('www.example.net', 'abc') # ===> "abc\n"
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
### Dynamically evaluated raw responses recorded with `curl -is`
@@ -217,90 +217,90 @@ You can also use WebMock outside a test framework:
stub_request(:any, 'www.example.net').
to_return(:body => lambda { |request| request.body })
- RestClient.post('www.example.net', 'abc') # ===> "abc\n"
+ RestClient.post('www.example.net', 'abc') # ===> "abc\n"
### Raising errors
#### Exception declared by class
- stub_request(:any, 'www.example.net').to_raise(StandardError)
+ stub_request(:any, 'www.example.net').to_raise(StandardError)
RestClient.post('www.example.net', 'abc') # ===> StandardError
-
+
#### or by exception instance
stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
#### or by string
-
+
stub_request(:any, 'www.example.net').to_raise("some error")
### Raising timeout errors
- stub_request(:any, 'www.example.net').to_timeout
+ stub_request(:any, 'www.example.net').to_timeout
- RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
+ RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
### Multiple responses for repeated requests
- stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
-
- #after all responses are used the last response will be returned infinitely
-
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
+ stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
+
+ #after all responses are used the last response will be returned infinitely
+
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
### Multiple responses using chained `to_return()`, `to_raise()` or `to_timeout` declarations
- stub_request(:get, "www.example.com").
- to_return({:body => "abc"}).then. #then() is just a syntactic sugar
- to_return({:body => "def"}).then.
- to_raise(MyException)
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
- Net::HTTP.get('www.example.com', '/') # ===> MyException raised
+ stub_request(:get, "www.example.com").
+ to_return({:body => "abc"}).then. #then() is just a syntactic sugar
+ to_return({:body => "def"}).then.
+ to_raise(MyException)
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
+ Net::HTTP.get('www.example.com', '/') # ===> MyException raised
### Specifying number of times given response should be returned
- stub_request(:get, "www.example.com").
- to_return({:body => "abc"}).times(2).then.
- to_return({:body => "def"})
+ stub_request(:get, "www.example.com").
+ to_return({:body => "abc"}).times(2).then.
+ to_return({:body => "def"})
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
- Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
- Net::HTTP.get('www.example.com', '/') # ===> "def\n"
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
+ Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
+ Net::HTTP.get('www.example.com', '/') # ===> "def\n"
### Real requests to network can be allowed or disabled
- WebMock.allow_net_connect!
+ WebMock.allow_net_connect!
- stub_request(:any, "www.example.com").to_return(:body => "abc")
+ stub_request(:any, "www.example.com").to_return(:body => "abc")
- Net::HTTP.get('www.example.com', '/') # ===> "abc"
-
- Net::HTTP.get('www.something.com', '/') # ===> /.+Something.+/
-
- WebMock.disable_net_connect!
-
- Net::HTTP.get('www.something.com', '/') # ===> Failure
+ Net::HTTP.get('www.example.com', '/') # ===> "abc"
+
+ Net::HTTP.get('www.something.com', '/') # ===> /.+Something.+/
+
+ WebMock.disable_net_connect!
+
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
### External requests can be disabled while allowing localhost
-
- WebMock.disable_net_connect!(:allow_localhost => true)
-
- Net::HTTP.get('www.something.com', '/') # ===> Failure
-
- Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
+
+ WebMock.disable_net_connect!(:allow_localhost => true)
+
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
+
+ Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
### External requests can be disabled while allowing any hostname
- WebMock.disable_net_connect!(:allow => "www.example.org")
+ WebMock.disable_net_connect!(:allow => "www.example.org")
- Net::HTTP.get('www.something.com', '/') # ===> Failure
+ Net::HTTP.get('www.something.com', '/') # ===> Failure
- Net::HTTP.get('www.example.org', '/') # ===> Allowed.
+ Net::HTTP.get('www.example.org', '/') # ===> Allowed.
## Connecting on Net::HTTP.start
@@ -317,84 +317,84 @@ so when there is no request, `Net::HTTP.start` doesn't do anything.
To workaround this issue, WebMock offers `:net_http_connect_on_start` option,
which can be passed to `WebMock.allow_net_connect!` and `WebMock#disable_net_connect!` methods, i.e.
- WebMock.allow_net_connect!(:net_http_connect_on_start => true)
+ WebMock.allow_net_connect!(:net_http_connect_on_start => true)
This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
## Setting Expectations
### Setting expectations in Test::Unit
- require 'webmock/test_unit'
+ require 'webmock/test_unit'
stub_request(:any, "www.example.com")
- uri = URI.parse('http://www.example.com/')
+ uri = URI.parse('http://www.example.com/')
req = Net::HTTP::Post.new(uri.path)
- req['Content-Length'] = 3
+ req['Content-Length'] = 3
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req, 'abc')
}
- assert_requested :post, "http://www.example.com",
- :headers => {'Content-Length' => 3}, :body => "abc", :times => 1 # ===> Success
-
- assert_not_requested :get, "http://www.something.com" # ===> Success
+ assert_requested :post, "http://www.example.com",
+ :headers => {'Content-Length' => 3}, :body => "abc", :times => 1 # ===> Success
+
+ assert_not_requested :get, "http://www.something.com" # ===> Success
- assert_requested(:post, "http://www.example.com", :times => 1) { |req| req.body == "abc" }
+ assert_requested(:post, "http://www.example.com", :times => 1) { |req| req.body == "abc" }
### Expecting real (not stubbed) requests
- WebMock.allow_net_connect!
-
- Net::HTTP.get('www.example.com', '/') # ===> Success
+ WebMock.allow_net_connect!
+
+ Net::HTTP.get('www.example.com', '/') # ===> Success
- assert_requested :get, "http://www.example.com" # ===> Success
+ assert_requested :get, "http://www.example.com" # ===> Success
### Setting expectations in RSpec
This style is borrowed from [fakeweb-matcher](http://github.com/freelancing-god/fakeweb-matcher)
- require 'webmock/rspec'
+ require 'webmock/rspec'
+
+ WebMock.should have_requested(:get, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).twice
+
+ WebMock.should_not have_requested(:get, "www.something.com")
+
+ WebMock.should have_requested(:post, "www.example.com").with { |req| req.body == "abc" }
- WebMock.should have_requested(:get, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).twice
-
- WebMock.should_not have_requested(:get, "www.something.com")
-
- WebMock.should have_requested(:post, "www.example.com").with { |req| req.body == "abc" }
-
- WebMock.should have_requested(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
+ WebMock.should have_requested(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
- WebMock.should have_requested(:get, "www.example.com").
- with(:body => {"a" => ["b", "c"]}, :headers => 'Content-Type' => 'application/json')
+ WebMock.should have_requested(:get, "www.example.com").
+ with(:body => {"a" => ["b", "c"]}, :headers => 'Content-Type' => 'application/json')
### Different way of setting expectations in RSpec
- a_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
- a_request(:post, "www.something.com").should have_been_made.times(3)
+ a_request(:post, "www.something.com").should have_been_made.times(3)
- a_request(:any, "www.example.com").should_not have_been_made
+ a_request(:any, "www.example.com").should_not have_been_made
- a_request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
+ 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(: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
+ 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!`
- stub_request(:any, "www.example.com")
+ stub_request(:any, "www.example.com")
- Net::HTTP.get('www.example.com', '/') # ===> Success
+ Net::HTTP.get('www.example.com', '/') # ===> Success
- WebMock.reset!
+ WebMock.reset!
- Net::HTTP.get('www.example.com', '/') # ===> Failure
+ Net::HTTP.get('www.example.com', '/') # ===> Failure
- assert_not_requested :get, "www.example.com" # ===> Success
+ assert_not_requested :get, "www.example.com" # ===> Success
## Matching requests
@@ -411,14 +411,14 @@ An executed request matches stubbed request if it passes following criteria:
Always the last declared stub matching the request will be applied i.e:
- stub_request(:get, "www.example.com").to_return(:body => "abc")
- stub_request(:get, "www.example.com").to_return(:body => "def")
+ stub_request(:get, "www.example.com").to_return(:body => "abc")
+ stub_request(:get, "www.example.com").to_return(:body => "def")
- Net::HTTP.get('www.example.com', '/') # ====> "def"
+ Net::HTTP.get('www.example.com', '/') # ====> "def"
## Matching URIs
-WebMock will match all different representations of the same URI.
+WebMock will match all different representations of the same URI.
I.e all the following representations of the URI are equal:
@@ -430,36 +430,36 @@ I.e all the following representations of the URI are equal:
"http://www.example.com/"
"http://www.example.com:80"
"http://www.example.com:80/"
-
+
The following URIs with basic authentication are also equal for WebMock
- "a b:pass@www.example.com"
- "a b:pass@www.example.com/"
- "a b:pass@www.example.com:80"
- "a b:pass@www.example.com:80/"
- "http://a b:pass@www.example.com"
- "http://a b:pass@www.example.com/"
- "http://a b:pass@www.example.com:80"
- "http://a b:pass@www.example.com:80/"
- "a%20b:pass@www.example.com"
- "a%20b:pass@www.example.com/"
- "a%20b:pass@www.example.com:80"
- "a%20b:pass@www.example.com:80/"
- "http://a%20b:pass@www.example.com"
- "http://a%20b:pass@www.example.com/"
- "http://a%20b:pass@www.example.com:80"
- "http://a%20b:pass@www.example.com:80/"
+ "a b:pass@www.example.com"
+ "a b:pass@www.example.com/"
+ "a b:pass@www.example.com:80"
+ "a b:pass@www.example.com:80/"
+ "http://a b:pass@www.example.com"
+ "http://a b:pass@www.example.com/"
+ "http://a b:pass@www.example.com:80"
+ "http://a b:pass@www.example.com:80/"
+ "a%20b:pass@www.example.com"
+ "a%20b:pass@www.example.com/"
+ "a%20b:pass@www.example.com:80"
+ "a%20b:pass@www.example.com:80/"
+ "http://a%20b:pass@www.example.com"
+ "http://a%20b:pass@www.example.com/"
+ "http://a%20b:pass@www.example.com:80"
+ "http://a%20b:pass@www.example.com:80/"
or these
- "www.example.com/my path/?a=my param&b=c"
- "www.example.com/my%20path/?a=my%20param&b=c"
- "www.example.com:80/my path/?a=my param&b=c"
- "www.example.com:80/my%20path/?a=my%20param&b=c"
- "http://www.example.com/my path/?a=my param&b=c"
- "http://www.example.com/my%20path/?a=my%20param&b=c"
- "http://www.example.com:80/my path/?a=my param&b=c"
- "http://www.example.com:80/my%20path/?a=my%20param&b=c"
+ "www.example.com/my path/?a=my param&b=c"
+ "www.example.com/my%20path/?a=my%20param&b=c"
+ "www.example.com:80/my path/?a=my param&b=c"
+ "www.example.com:80/my%20path/?a=my%20param&b=c"
+ "http://www.example.com/my path/?a=my param&b=c"
+ "http://www.example.com/my%20path/?a=my%20param&b=c"
+ "http://www.example.com:80/my path/?a=my param&b=c"
+ "http://www.example.com:80/my%20path/?a=my%20param&b=c"
If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
@@ -515,6 +515,51 @@ If you have any suggestions on how to improve WebMock please send an email to th
I'm particularly interested in how the DSL could be improved.
+## Development
+
+In order to work on Webmock you first need to fork and clone the repo.
+Please do any work on a dedicated branch and rebase against master
+before sending a pull request.
+
+#### Running Tests
+
+We use RVM in order to test WebMock against 1.8.6, REE, 1.8.7, 1.9.2 and
+jRuby. You can get RVM setup for WebMock development using the
+following commands (if you don't have these version of Ruby installed
+use `rvm install` to install each of them).
+
+ rvm use --create 1.8.6@webmock
+ gem install jeweler bundler
+ bundle install
+
+ rvm use --create ree@webmock
+ gem install jeweler bundler
+ bundle install
+
+ rvm use --create 1.8.7@webmock
+ gem install jeweler bundler
+ bundle install
+
+ rvm use --create 1.9.2@webmock
+ gem install jeweler bundler
+ bundle install
+
+ rvm use --create jruby@webmock
+ gem install jeweler bundler
+ bundle install
+
+These commands will create a gemset named WebMock for each of the
+supported versions of Ruby and `bundle install` all dependencies.
+
+With the supported versions of Ruby installed RVM will run specs across
+all version with just one command.
+
+ bundle exec rvm 1.8.6@webmock,ree@webmock,1.8.7@webmock,1.9.2@webmock,jruby@webmock rspec spec/**/*_spec.rb
+
+This command is wrapped up in to a rake task and can be invoked like so:
+
+ rake spec:rubies
+
## Credits
The initial lines of this project were written during New Bamboo [Hack Day](http://blog.new-bamboo.co.uk/2009/11/13/hackday-results)
@@ -553,10 +598,13 @@ People who submitted patches and new features or suggested improvements. Many th
* Sam Stokes
* Eugene Bolshakov
+For a full list of contributors you can visit the
+[contributors](https://github.com/bblimke/webmock/contributors) page.
+
## Background
Thank you Fakeweb! This library was inspired by [FakeWeb](fakeweb.rubyforge.org).
-I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
+I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
Fakeweb architecture unfortunately didn't allow me to extend it easily with the features I needed.
I also preferred some things to work differently i.e request stub precedence.
View
11 Rakefile
@@ -23,6 +23,17 @@ rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
+namespace :spec do
+ desc 'Run specs against 1.8.6, REE, 1.8.7, 1.9.2 and jRuby'
+ task :rubies do
+ # JCF: I'd love to be able to use RVM's `rvm {rubies} specs` command but
+ # the require tests in spec/other_net_http_libs_spec.rb break when doing
+ # so.
+ spec_files = Dir[File.dirname(__FILE__) + '/spec/**/*_spec.rb'].join(' ')
+ sh "rvm 1.8.6@webmock,ree@webmock,1.8.7@webmock,1.9.2@webmock,jruby@webmock exec rspec #{spec_files}"
+ end
+end
+
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
Please sign in to comment.
Something went wrong with that request. Please try again.