Skip to content
Newer
Older
100644 712 lines (462 sloc) 22.9 KB
672cad8 @laserlemon Add dependency status to README
laserlemon authored Jan 8, 2012
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)
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
2 =======
3
0016b13 Minor changes to README
Bartosz Blimke authored Jan 31, 2010
4 Library for stubbing and setting expectations on HTTP requests in Ruby.
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
5
6 Features
7 --------
8
0016b13 Minor changes to README
Bartosz Blimke authored Jan 31, 2010
9 * Stubbing HTTP requests at low http client lib level (no need to change tests when you change HTTP library)
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
10 * Setting and verifying expectations on HTTP requests
11 * Matching requests based on method, URI, headers and body
12 * Smart matching of the same URIs in different representations (also encoded and non encoded forms)
13 * Smart matching of the same headers in different representations.
9c8c463 Updated README with information about RSpec 2 support.
Bartosz Blimke authored May 14, 2010
14 * Support for Test::Unit
15 * Support for RSpec 1.x and RSpec 2.x
5627070 @bblimke Updated README with info about MiniTest support.
authored Aug 9, 2011
16 * Support for MiniTest
fb18a01 Updated README with info about matching request body against hash
Bartosz Blimke authored Jun 19, 2010
17
18 Supported HTTP libraries
19 ------------------------
20
3d84ef6 Added EM-HTTP-Request to the list of supported http clients
Bartosz Blimke authored Jun 20, 2010
21 * Net::HTTP and libraries based on Net::HTTP (i.e RightHttpConnection, REST Client, HTTParty)
fb18a01 Updated README with info about matching request body against hash
Bartosz Blimke authored Jun 19, 2010
22 * HTTPClient
23 * Patron
3d84ef6 Added EM-HTTP-Request to the list of supported http clients
Bartosz Blimke authored Jun 20, 2010
24 * EM-HTTP-Request
ed9ff32 @bblimke WebMock currently doesn't support Curb::Multi
authored Nov 15, 2010
25 * Curb (currently only Curb::Easy)
21aba84 @bblimke Updated README and Changelog with inf about Typhoeus support
authored Aug 9, 2011
26 * Typhoeus (currently only Typhoeus::Hydra)
68ba906 @bblimke Updated Changelog and Readme with the latest changes in master
authored Feb 5, 2012
27 * Excon
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
28
34c758e @bblimke Listed supported Ruby interpreters in README
authored Aug 9, 2011
29 Supported Ruby Interpreters
30 ---------------------------
31
32 * MRI 1.8.6
33 * MRI 1.8.7
34 * MRI 1.9.1
35 * MRI 1.9.2
68ba906 @bblimke Updated Changelog and Readme with the latest changes in master
authored Feb 5, 2012
36 * MRI 1.9.3
34c758e @bblimke Listed supported Ruby interpreters in README
authored Aug 9, 2011
37 * REE 1.8.7
38 * JRuby
163f678 @bblimke Fixed README formatting
authored Aug 9, 2011
39
f25a213 @bblimke Improved README on how to include WebMock in Test::Unit, RSpec and Cu…
authored Jul 16, 2010
40 ##Installation
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
41
51665d3 @rohit gemcutter is now rubygems so no need to specify source
rohit authored Jan 9, 2012
42 gem install webmock
7a8bab1 @bblimke Added info on how to install the latest development version of WebMoc…
authored Nov 3, 2010
43
44 ### or to install the latest development version from github master
45
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
46 git clone http://github.com/bblimke/webmock.git
47 cd webmock
48 rake install
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
49
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
50 ### Test::Unit
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
51
f25a213 @bblimke Improved README on how to include WebMock in Test::Unit, RSpec and Cu…
authored Jul 16, 2010
52 Add the following code to `test/test_helper.rb`
53
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
54 require 'webmock/test_unit'
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
55
f25a213 @bblimke Improved README on how to include WebMock in Test::Unit, RSpec and Cu…
authored Jul 16, 2010
56 ### RSpec
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
57
f25a213 @bblimke Improved README on how to include WebMock in Test::Unit, RSpec and Cu…
authored Jul 16, 2010
58 Add the following code to `spec/spec_helper`:
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
59
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
60 require 'webmock/rspec'
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
61
bd43897 @bblimke Added info about minitest support to README
authored Aug 9, 2011
62 ### MiniTest
63
64 Add the following code to `test/test_helper`:
65
66 require 'webmock/minitest'
67
f25a213 @bblimke Improved README on how to include WebMock in Test::Unit, RSpec and Cu…
authored Jul 16, 2010
68 ### Cucumber
69
70 Add the following code to `features/support/env.rb`
3ca443e WebMock module has to be included manually and is not included by RSp…
Bartosz Blimke authored Nov 24, 2009
71
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
72 require 'webmock/cucumber'
f25a213 @bblimke Improved README on how to include WebMock in Test::Unit, RSpec and Cu…
authored Jul 16, 2010
73
74 You can also use WebMock outside a test framework:
75
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
76 require 'webmock'
77 include WebMock::API
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
78
79 ## Examples
80
81
82
83 ## Stubbing
84
85
86 ### Stubbed request based on uri only and with the default response
87
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
88 stub_request(:any, "www.example.com")
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
89
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
90 Net::HTTP.get("www.example.com", "/") # ===> Success
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
91
92 ### Stubbing requests based on method, uri, body and headers
93
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
94 stub_request(:post, "www.example.com").with(:body => "abc", :headers => { 'Content-Length' => 3 })
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
95
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
96 uri = URI.parse("http://www.example.com/")
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
97 req = Net::HTTP::Post.new(uri.path)
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
98 req['Content-Length'] = 3
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
99 res = Net::HTTP.start(uri.host, uri.port) {|http|
100 http.request(req, "abc")
101 } # ===> Success
102
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
103 ### Matching request body and headers against regular expressions
104
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
105 stub_request(:post, "www.example.com").
106 with(:body => /^.*world$/, :headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
107
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
108 uri = URI.parse('http://www.example.com/')
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
109 req = Net::HTTP::Post.new(uri.path)
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
110 req['Content-Type'] = 'image/png'
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
111 res = Net::HTTP.start(uri.host, uri.port) {|http|
112 http.request(req, 'hello world')
113 } # ===> Success
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
114
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored Jun 21, 2010
115 ### Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
fb18a01 Updated README with info about matching request body against hash
Bartosz Blimke authored Jun 19, 2010
116
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
117 stub_http_request(:post, "www.example.com").
118 with(:body => {:data => {:a => '1', :b => 'five'}})
119
120 RestClient.post('www.example.com', "data[a]=1&data[b]=five",
121 :content_type => 'application/x-www-form-urlencoded') # ===> Success
fb18a01 Updated README with info about matching request body against hash
Bartosz Blimke authored Jun 19, 2010
122
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
123 RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
124 :content_type => 'application/json') # ===> Success
125
126 RestClient.post('www.example.com', '<data a="1" b="five" />',
127 :content_type => 'application/xml' ) # ===> Success
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
128
336b143 @bblimke Matching request body against partial hash with hash_including matcher.
authored Feb 5, 2012
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
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
137 ### Matching custom request headers
138
0016b13 Minor changes to README
Bartosz Blimke authored Jan 31, 2010
139 stub_request(:any, "www.example.com").with(:headers=>{ 'Header-Name' => 'Header-Value' })
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
140
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
141 uri = URI.parse('http://www.example.com/')
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
142 req = Net::HTTP::Post.new(uri.path)
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
143 req['Header-Name'] = 'Header-Value'
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
144 res = Net::HTTP.start(uri.host, uri.port) {|http|
145 http.request(req, 'abc')
146 } # ===> Success
147
176482c Updated README with 1.1.0 changes
Bartosz Blimke authored Apr 28, 2010
148 ### Matching multiple headers with the same name
149
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
150 stub_http_request(:get, 'www.example.com').with(:headers => {'Accept' => ['image/jpeg', 'image/png'] })
151
152 req = Net::HTTP::Get.new("/")
153 req['Accept'] = ['image/png']
154 req.add_field('Accept', 'image/jpeg')
155 Net::HTTP.start("www.example.com") {|http| http.request(req) } # ===> Success
176482c Updated README with 1.1.0 changes
Bartosz Blimke authored Apr 28, 2010
156
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
157 ### Matching requests against provided block
158
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
159 stub_request(:post, "www.example.com").with { |request| request.body == "abc" }
160 RestClient.post('www.example.com', 'abc') # ===> Success
161
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
162 ### Request with basic authentication
163
164 stub_request(:get, "user:pass@www.example.com")
165
166 Net::HTTP.start('www.example.com') {|http|
167 req = Net::HTTP::Get.new('/')
168 req.basic_auth 'user', 'pass'
169 http.request(req)
170 } # ===> Success
171
172 ### Matching uris using regular expressions
173
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
174 stub_request(:any, /.*example.*/)
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
175
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
176 Net::HTTP.get('www.example.com', '/') # ===> Success
177
178 ### Matching query params using hash
179
180 stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
181
182 RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
183
2d03aca @bblimke Added support for matching partial query params with "hash_including"
authored Feb 5, 2012
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
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
190 ### Stubbing with custom response
191
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
192 stub_request(:any, "www.example.com").to_return(:body => "abc", :status => 200, :headers => { 'Content-Length' => 3 } )
193
194 Net::HTTP.get("www.example.com", '/') # ===> "abc"
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
195
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
196 ### Response with body specified as IO object
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
197
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
198 File.open('/tmp/response_body.txt', 'w') { |f| f.puts 'abc' }
199
200 stub_request(:any, "www.example.com").to_return(:body => File.new('/tmp/response_body.txt'), :status => 200)
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
201
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
202 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
203
3314aad Added support for status messages
Bartosz Blimke authored Mar 14, 2010
204 ### Response with custom status message
205
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
206 stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
207
208 req = Net::HTTP::Get.new("/")
209 Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
3314aad Added support for status messages
Bartosz Blimke authored Mar 14, 2010
210
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
211 ### Replaying raw responses recorded with `curl -is`
212
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
213 `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
214 raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
215
216 from file
217
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
218 stub_request(:get, "www.example.com").to_return(raw_response_file)
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
219
220 or string
221
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
222 stub_request(:get, "www.example.com").to_return(raw_response_file.read)
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
223
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
224 ### Responses dynamically evaluated from block
225
4e0568a Added information about dynamic responses to README
Bartosz Blimke authored Dec 10, 2009
226 stub_request(:any, 'www.example.net').
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
227 to_return { |request| {:body => request.body} }
4e0568a Added information about dynamic responses to README
Bartosz Blimke authored Dec 10, 2009
228
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
229 RestClient.post('www.example.net', 'abc') # ===> "abc\n"
f0408f8 @bblimke Added support for dynamically evaluated raw responses recorded with `…
authored Oct 25, 2010
230
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
231 ### Responses dynamically evaluated from lambda
f0408f8 @bblimke Added support for dynamically evaluated raw responses recorded with `…
authored Oct 25, 2010
232
5b1c97b @tomafro Added complete dynamic request, where headers, body and status can al…
tomafro authored Feb 26, 2010
233 stub_request(:any, 'www.example.net').
234 to_return(lambda { |request| {:body => request.body} })
235
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
236 RestClient.post('www.example.net', 'abc') # ===> "abc\n"
4e0568a Added information about dynamic responses to README
Bartosz Blimke authored Dec 10, 2009
237
f0408f8 @bblimke Added support for dynamically evaluated raw responses recorded with `…
authored Oct 25, 2010
238 ### Dynamically evaluated raw responses recorded with `curl -is`
239
240 `curl -is www.example.com > /tmp/www.example.com.txt`
241 stub_request(:get, "www.example.com").to_return(lambda { |request| File.new("/tmp/#{request.uri.host.to_s}.txt" }))
242
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
243 ### Responses with dynamically evaluated parts
244
245 stub_request(:any, 'www.example.net').
246 to_return(:body => lambda { |request| request.body })
247
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
248 RestClient.post('www.example.net', 'abc') # ===> "abc\n"
0f3bb21 Updated README regarding dynamic responses
Bartosz Blimke authored Mar 13, 2010
249
c6974db @bblimke Added info about how to stub requests to respond with Rack app response.
authored Jul 31, 2011
250 ### Rack responses
251
252 class MyRackApp
253 def self.call(env)
254 [200, {}, ["Hello"]]
255 end
256 end
257
258 stub_request(:get, "www.example.com").to_rack(MyRackApp)
259
260 RestClient.post('www.example.com') # ===> "Hello"
261
af52fe7 Added support for declaring timeout errors using `to_timeout`
Bartosz Blimke authored Mar 14, 2010
262 ### Raising errors
263
207443e `to_raise()` now accepts exception instance or a string as argument i…
Bartosz Blimke authored Jun 19, 2010
264 #### Exception declared by class
265
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
266 stub_request(:any, 'www.example.net').to_raise(StandardError)
af52fe7 Added support for declaring timeout errors using `to_timeout`
Bartosz Blimke authored Mar 14, 2010
267
268 RestClient.post('www.example.net', 'abc') # ===> StandardError
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
269
207443e `to_raise()` now accepts exception instance or a string as argument i…
Bartosz Blimke authored Jun 18, 2010
270 #### or by exception instance
271
272 stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
273
274 #### or by string
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
275
207443e `to_raise()` now accepts exception instance or a string as argument i…
Bartosz Blimke authored Jun 18, 2010
276 stub_request(:any, 'www.example.net').to_raise("some error")
af52fe7 Added support for declaring timeout errors using `to_timeout`
Bartosz Blimke authored Mar 14, 2010
277
278 ### Raising timeout errors
279
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
280 stub_request(:any, 'www.example.net').to_timeout
af52fe7 Added support for declaring timeout errors using `to_timeout`
Bartosz Blimke authored Mar 14, 2010
281
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
282 RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
af52fe7 Added support for declaring timeout errors using `to_timeout`
Bartosz Blimke authored Mar 14, 2010
283
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
284 ### Multiple responses for repeated requests
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
285
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
286 stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
287 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
288 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
289
290 #after all responses are used the last response will be returned infinitely
291
292 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
bb41263 Improved section about basic authentication support in readme.
Bartosz Blimke authored Dec 10, 2009
293
af52fe7 Added support for declaring timeout errors using `to_timeout`
Bartosz Blimke authored Mar 14, 2010
294 ### Multiple responses using chained `to_return()`, `to_raise()` or `to_timeout` declarations
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
295
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
296 stub_request(:get, "www.example.com").
297 to_return({:body => "abc"}).then. #then() is just a syntactic sugar
298 to_return({:body => "def"}).then.
299 to_raise(MyException)
300 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
301 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
302 Net::HTTP.get('www.example.com', '/') # ===> MyException raised
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
303
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
304 ### Specifying number of times given response should be returned
305
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
306 stub_request(:get, "www.example.com").
307 to_return({:body => "abc"}).times(2).then.
308 to_return({:body => "def"})
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
309
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
310 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
311 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
312 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
313
314
315 ### Real requests to network can be allowed or disabled
316
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
317 WebMock.allow_net_connect!
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
318
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
319 stub_request(:any, "www.example.com").to_return(:body => "abc")
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
320
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
321 Net::HTTP.get('www.example.com', '/') # ===> "abc"
322
323 Net::HTTP.get('www.something.com', '/') # ===> /.+Something.+/
324
325 WebMock.disable_net_connect!
326
327 Net::HTTP.get('www.something.com', '/') # ===> Failure
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
328
8859deb @MacksMind Change the locahost option syntax and update README
MacksMind authored Apr 3, 2010
329 ### External requests can be disabled while allowing localhost
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
330
331 WebMock.disable_net_connect!(:allow_localhost => true)
332
333 Net::HTTP.get('www.something.com', '/') # ===> Failure
334
335 Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
336
7a38e8a @thenoseman Allow Webmock.disable_net_connect! to accept a RegEx as :allow option
thenoseman authored Feb 3, 2012
337 ### External requests can be disabled while allowing any hostname or port or parts thereof
67a0819 @bblimke Version 1.3.5 changelog + updated docs
authored Sep 6, 2010
338
e1d431e @bblimke Updated README with info about :allow with specified port number
authored Aug 9, 2011
339 WebMock.disable_net_connect!(:allow => "www.example.org:8080")
67a0819 @bblimke Version 1.3.5 changelog + updated docs
authored Sep 6, 2010
340
e1d431e @bblimke Updated README with info about :allow with specified port number
authored Aug 9, 2011
341 RestClient.get('www.something.com', '/') # ===> Failure
342
343 RestClient.get('www.example.org', '/') # ===> Failure.
67a0819 @bblimke Version 1.3.5 changelog + updated docs
authored Sep 6, 2010
344
e1d431e @bblimke Updated README with info about :allow with specified port number
authored Aug 9, 2011
345 RestClient.get('www.example.org:8080', '/') # ===> Allowed
67a0819 @bblimke Version 1.3.5 changelog + updated docs
authored Sep 6, 2010
346
7a38e8a @thenoseman Allow Webmock.disable_net_connect! to accept a RegEx as :allow option
thenoseman authored Feb 3, 2012
347 WebMock.disable_net_connect!(:allow => /ample.org/)
348
349 RestClient.get('www.example.org', '/') # ===> Allowed
67a0819 @bblimke Version 1.3.5 changelog + updated docs
authored Sep 6, 2010
350
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
351 ## Connecting on Net::HTTP.start
352
c92144f @bblimke Fixed text formatting in README
authored Nov 2, 2010
353 HTTP protocol has 3 steps: connect, request and response (or 4 with close). Most Ruby HTTP client libraries
354 treat connect as a part of request step, with the exception of `Net::HTTP` which
355 allows opening connection to the server separately to the request, by using `Net::HTTP.start`.
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
356
c92144f @bblimke Fixed text formatting in README
authored Nov 2, 2010
357 WebMock API was also designed with connect being part of request step, and it only allows stubbing
358 requests, not connections. When `Net::HTTP.start` is called, WebMock doesn't know yet whether
359 a request is stubbed or not. WebMock by default delays a connection until the request is invoked,
360 so when there is no request, `Net::HTTP.start` doesn't do anything.
361 **This means that WebMock breaks the Net::HTTP behaviour by default!**
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
362
079a719 @bblimke Updated changelog with version 1.5.0 changes
authored Nov 2, 2010
363 To workaround this issue, WebMock offers `:net_http_connect_on_start` option,
364 which can be passed to `WebMock.allow_net_connect!` and `WebMock#disable_net_connect!` methods, i.e.
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
365
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
366 WebMock.allow_net_connect!(:net_http_connect_on_start => true)
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
367
c92144f @bblimke Fixed text formatting in README
authored Nov 2, 2010
368 This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
369
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
370 ## Setting Expectations
371
372 ### Setting expectations in Test::Unit
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
373 require 'webmock/test_unit'
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
374
32c653c Replaced google with example in README
Bartosz Blimke authored Dec 11, 2009
375 stub_request(:any, "www.example.com")
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
376
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
377 uri = URI.parse('http://www.example.com/')
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
378 req = Net::HTTP::Post.new(uri.path)
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
379 req['Content-Length'] = 3
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
380 res = Net::HTTP.start(uri.host, uri.port) {|http|
381 http.request(req, 'abc')
382 }
383
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
384 assert_requested :post, "http://www.example.com",
385 :headers => {'Content-Length' => 3}, :body => "abc", :times => 1 # ===> Success
386
387 assert_not_requested :get, "http://www.something.com" # ===> Success
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
388
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
389 assert_requested(:post, "http://www.example.com", :times => 1) { |req| req.body == "abc" }
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored Jan 31, 2010
390
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
391 ### Expecting real (not stubbed) requests
392
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
393 WebMock.allow_net_connect!
394
395 Net::HTTP.get('www.example.com', '/') # ===> Success
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
396
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
397 assert_requested :get, "http://www.example.com" # ===> Success
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
398
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not…
nfo authored Sep 7, 2011
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
ed795fa @bblimke assert_requested and assert_not_requested can accept either method an…
authored Feb 4, 2012
406 assert_requested(stub_get)
407 assert_not_requested(stub_post)
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not…
nfo authored Sep 7, 2011
408
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
409
a6e0800 @afeld allow expectations to be set on the stub itself
afeld authored Jun 6, 2011
410 ### Setting expectations in RSpec on `WebMock` module
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
411 This style is borrowed from [fakeweb-matcher](http://github.com/freelancing-god/fakeweb-matcher)
412
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
413 require 'webmock/rspec'
414
415 WebMock.should have_requested(:get, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).twice
416
417 WebMock.should_not have_requested(:get, "www.something.com")
418
419 WebMock.should have_requested(:post, "www.example.com").with { |req| req.body == "abc" }
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
420
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
421 WebMock.should have_requested(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
fa4ab29 Updated README with info about setting expectations on query params o…
Bartosz Blimke authored Jun 19, 2010
422
2d03aca @bblimke Added support for matching partial query params with "hash_including"
authored Feb 5, 2012
423 WebMock.should have_requested(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]}))
424
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
425 WebMock.should have_requested(:get, "www.example.com").
c109d95 @fb3 Fixed syntax error in README examples
fb3 authored May 25, 2011
426 with(:body => {"a" => ["b", "c"]}, :headers => {'Content-Type' => 'application/json'})
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
427
a6e0800 @afeld allow expectations to be set on the stub itself
afeld authored Jun 6, 2011
428 ### Setting expectations in RSpec with `a_request`
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
429
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
430 a_request(:post, "www.example.com").with(:body => "abc", :headers => {'Content-Length' => 3}).should have_been_made.once
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
431
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
432 a_request(:post, "www.something.com").should have_been_made.times(3)
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
433
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
434 a_request(:any, "www.example.com").should_not have_been_made
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
435
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
436 a_request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
6cb45ed @bblimke Renames WebMock#request to WebMock#a_request to avoid conflicts with …
authored Oct 6, 2010
437
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
438 a_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made
6cb45ed @bblimke Renames WebMock#request to WebMock#a_request to avoid conflicts with …
authored Oct 6, 2010
439
2d03aca @bblimke Added support for matching partial query params with "hash_including"
authored Feb 5, 2012
440 a_request(:get, "www.example.com").with(:query => hash_including({"a" => ["b", "c"]})).should have_been_made
441
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
442 a_request(:post, "www.example.com").
c109d95 @fb3 Fixed syntax error in README examples
fb3 authored May 25, 2011
443 with(:body => {"a" => ["b", "c"]}, :headers => {'Content-Type' => 'application/json'}).should have_been_made
6cb45ed @bblimke Renames WebMock#request to WebMock#a_request to avoid conflicts with …
authored Oct 6, 2010
444
a6e0800 @afeld allow expectations to be set on the stub itself
afeld authored Jun 6, 2011
445 ### Setting expectations in RSpec on the stub
446
447 stub = stub_request(:get, "www.example.com")
448 # ... make requests ...
449 stub.should have_been_requested
450
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
451 ## Clearing stubs and request history
452
473b709 @bblimke Added WebMock.reset! method. WebMock.reset_webmock is now deprecated
authored Nov 3, 2010
453 If you want to reset all current stubs and history of requests use `WebMock.reset!`
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
454
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
455 stub_request(:any, "www.example.com")
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
456
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
457 Net::HTTP.get('www.example.com', '/') # ===> Success
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
458
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
459 WebMock.reset!
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
460
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
461 Net::HTTP.get('www.example.com', '/') # ===> Failure
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
462
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
463 assert_not_requested :get, "www.example.com" # ===> Success
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
464
17547a5 @bblimke Updated Changelog and README with info about enabling and disabling W…
authored Aug 14, 2011
465 ## Disabling and enabling WebMock or only some http client adapters
466
467 WebMock.disable! #disable WebMock (all adapters)
607e1e8 @bblimke Added more examples to 1.7.0.pre Changelog
authored Aug 14, 2011
468 WebMock.disable!(:except => [:net_http]) #disable WebMock for all libs except Net::HTTP
17547a5 @bblimke Updated Changelog and README with info about enabling and disabling W…
authored Aug 13, 2011
469 WebMock.enable! #enable WebMock (all adapters)
607e1e8 @bblimke Added more examples to 1.7.0.pre Changelog
authored Aug 14, 2011
470 WebMock.enable!(:except => [:patron]) #enable WebMock for all libs except Patron
17547a5 @bblimke Updated Changelog and README with info about enabling and disabling W…
authored Aug 13, 2011
471
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
472
473 ## Matching requests
474
475 An executed request matches stubbed request if it passes following criteria:
476
4306efa Ability to register and expect requests with empty body.
Bartosz Blimke authored Nov 30, 2009
477 When request URI matches stubbed request URI string or Regexp pattern<br/>
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
478 And request method is the same as stubbed request method or stubbed request method is :any<br/>
4306efa Ability to register and expect requests with empty body.
Bartosz Blimke authored Nov 30, 2009
479 And request body is the same as stubbed request body or stubbed request body is not specified<br/>
0016b13 Minor changes to README
Bartosz Blimke authored Jan 31, 2010
480 And request headers match stubbed request headers, or stubbed request headers match a subset of request headers, or stubbed request headers are not specified<br/>
481 And request matches provided block or block is not provided
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
482
483 ## Precedence of stubs
484
485 Always the last declared stub matching the request will be applied i.e:
486
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
487 stub_request(:get, "www.example.com").to_return(:body => "abc")
488 stub_request(:get, "www.example.com").to_return(:body => "def")
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
489
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
490 Net::HTTP.get('www.example.com', '/') # ====> "def"
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
491
492 ## Matching URIs
493
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
494 WebMock will match all different representations of the same URI.
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
495
496 I.e all the following representations of the URI are equal:
497
32c653c Replaced google with example in README
Bartosz Blimke authored Dec 11, 2009
498 "www.example.com"
499 "www.example.com/"
500 "www.example.com:80"
501 "www.example.com:80/"
502 "http://www.example.com"
503 "http://www.example.com/"
504 "http://www.example.com:80"
505 "http://www.example.com:80/"
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
506
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
507 The following URIs with basic authentication are also equal for WebMock
508
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
509 "a b:pass@www.example.com"
510 "a b:pass@www.example.com/"
511 "a b:pass@www.example.com:80"
512 "a b:pass@www.example.com:80/"
513 "http://a b:pass@www.example.com"
514 "http://a b:pass@www.example.com/"
515 "http://a b:pass@www.example.com:80"
516 "http://a b:pass@www.example.com:80/"
517 "a%20b:pass@www.example.com"
518 "a%20b:pass@www.example.com/"
519 "a%20b:pass@www.example.com:80"
520 "a%20b:pass@www.example.com:80/"
521 "http://a%20b:pass@www.example.com"
522 "http://a%20b:pass@www.example.com/"
523 "http://a%20b:pass@www.example.com:80"
524 "http://a%20b:pass@www.example.com:80/"
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
525
526 or these
527
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
528 "www.example.com/my path/?a=my param&b=c"
529 "www.example.com/my%20path/?a=my%20param&b=c"
530 "www.example.com:80/my path/?a=my param&b=c"
531 "www.example.com:80/my%20path/?a=my%20param&b=c"
532 "http://www.example.com/my path/?a=my param&b=c"
533 "http://www.example.com/my%20path/?a=my%20param&b=c"
534 "http://www.example.com:80/my path/?a=my param&b=c"
535 "http://www.example.com:80/my%20path/?a=my%20param&b=c"
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
536
537
538 If you provide Regexp to match URI, WebMock will try to match it against every valid form of the same url.
539
78414b7 Improved examples with equality of URIs with the same parameters
Bartosz Blimke authored Dec 11, 2009
540 I.e `/.*my param.*/` will match `www.example.com/my%20path` because it is equivalent of `www.example.com/my path`
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
541
542
543 ## Matching headers
544
545 WebMock will match request headers against stubbed request headers in the following situations:
546
547 1. Stubbed request has headers specified and request headers are the same as stubbed headers <br/>
548 i.e stubbed headers: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`, requested: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`
549
550 2. Stubbed request has headers specified and stubbed request headers are a subset of request headers <br/>
551 i.e stubbed headers: `{ 'Header1' => 'Value1' }`, requested: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`
552
553 3. Stubbed request has no headers <br/>
554 i.e stubbed headers: `nil`, requested: `{ 'Header1' => 'Value1', 'Header1' => 'Value1' }`
555
556 WebMock normalises headers and treats all forms of same headers as equal:
557 i.e the following two sets of headers are equal:
558
559 `{ "Header1" => "value1", :content_length => 123, :X_CuStOm_hEAder => :value }`
560
561 `{ :header1 => "value1", "Content-Length" => 123, "x-cuSTOM-HeAder" => "value" }`
562
176482c Updated README with 1.1.0 changes
Bartosz Blimke authored Apr 28, 2010
563 ## Recording real requests and responses and replaying them later
564
565 To record your application's real HTTP interactions and replay them later in tests you can use [VCR](http://github.com/myronmarston/vcr) with WebMock.
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
566
5331132 Updated README with information about request callbacks
Bartosz Blimke authored Jun 19, 2010
567 ## Request callbacks
568
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored Jun 20, 2010
569 ####WebMock can invoke callbacks stubbed or real requests:
5331132 Updated README with information about request callbacks
Bartosz Blimke authored Jun 18, 2010
570
571 WebMock.after_request do |request_signature, response|
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored Jun 20, 2010
572 puts "Request #{request_signature} was made and #{response} was returned"
5331132 Updated README with information about request callbacks
Bartosz Blimke authored Jun 18, 2010
573 end
574
575 #### invoke callbacks for real requests only and except requests made with Patron
576
577 WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored Jun 20, 2010
578 puts "Request #{request_signature} was made and #{response} was returned"
5331132 Updated README with information about request callbacks
Bartosz Blimke authored Jun 18, 2010
579 end
580
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
581 ## Bugs and Issues
582
583 Please submit them here [http://github.com/bblimke/webmock/issues](http://github.com/bblimke/webmock/issues)
584
585 ## Suggestions
586
587 If you have any suggestions on how to improve WebMock please send an email to the mailing list [groups.google.com/group/webmock-users](http://groups.google.com/group/webmock-users)
588
589 I'm particularly interested in how the DSL could be improved.
590
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
591 ## Development
592
593 In order to work on Webmock you first need to fork and clone the repo.
594 Please do any work on a dedicated branch and rebase against master
595 before sending a pull request.
596
597 #### Running Tests
598
599 We use RVM in order to test WebMock against 1.8.6, REE, 1.8.7, 1.9.2 and
600 jRuby. You can get RVM setup for WebMock development using the
601 following commands (if you don't have these version of Ruby installed
602 use `rvm install` to install each of them).
603
604 rvm use --create 1.8.6@webmock
605 gem install jeweler bundler
606 bundle install
607
608 rvm use --create ree@webmock
609 gem install jeweler bundler
610 bundle install
611
612 rvm use --create 1.8.7@webmock
613 gem install jeweler bundler
614 bundle install
615
616 rvm use --create 1.9.2@webmock
617 gem install jeweler bundler
618 bundle install
619
620 rvm use --create jruby@webmock
621 gem install jeweler bundler
622 bundle install
623
624 These commands will create a gemset named WebMock for each of the
625 supported versions of Ruby and `bundle install` all dependencies.
626
627 With the supported versions of Ruby installed RVM will run specs across
628 all version with just one command.
629
630 bundle exec rvm 1.8.6@webmock,ree@webmock,1.8.7@webmock,1.9.2@webmock,jruby@webmock rspec spec/**/*_spec.rb
631
632 This command is wrapped up in to a rake task and can be invoked like so:
633
634 rake spec:rubies
635
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
636 ## Credits
637
00424d9 Updated credits in README
Bartosz Blimke authored Mar 26, 2010
638 The initial lines of this project were written during New Bamboo [Hack Day](http://blog.new-bamboo.co.uk/2009/11/13/hackday-results)
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
639 Thanks to my fellow [Bambinos](http://new-bamboo.co.uk/) for all the great suggestions!
640
00424d9 Updated credits in README
Bartosz Blimke authored Mar 26, 2010
641 People who submitted patches and new features or suggested improvements. Many thanks to these people:
642
643 * Ben Pickles
644 * Mark Evans
645 * Ivan Vega
646 * Piotr Usewicz
647 * Nick Plante
648 * Nick Quaranto
649 * Diego E. "Flameeyes" Pettenò
650 * Niels Meersschaert
651 * Mack Earnhardt
652 * Arvicco
653 * Sergio Gil
654 * Jeffrey Jones
655 * Tekin Suleyman
656 * Tom Ward
657 * Nadim Bitar
ee7b3b4 Fixed spelling
Bartosz Blimke authored Apr 29, 2010
658 * Myron Marston
9c8c463 Updated README with information about RSpec 2 support.
Bartosz Blimke authored May 14, 2010
659 * Sam Phillips
2e88f99 Updated info on how to include WebMock in Test::Unit and RSpec withou…
Bartosz Blimke authored May 21, 2010
660 * Jose Angel Cortinas
52698d8 Updated credits
Bartosz Blimke authored May 24, 2010
661 * Razic
fd2472a Version 1.2.2 changelog
Bartosz Blimke authored May 26, 2010
662 * Steve Tooke
fb18a01 Updated README with info about matching request body against hash
Bartosz Blimke authored Jun 19, 2010
663 * Nathaniel Bibler
15f888e @bblimke The less hacky way to get the stream behaviour working for em-http-re…
authored Jul 9, 2010
664 * Martyn Loughran
60fa244 @bblimke Updated changelog
authored Jul 9, 2010
665 * Muness Alrubaie
67a0819 @bblimke Version 1.3.5 changelog + updated docs
authored Sep 6, 2010
666 * Charles Li
667 * Ryan Bigg
aaf774b @bblimke Added info to changelog and readme about Curb support, implemented by…
authored Oct 4, 2010
668 * Pete Higgins
ffbcdb3 @bblimke Updated changelog with the latest changes in master branch
authored Oct 30, 2010
669 * Hans de Graaff
4e313c2 @bblimke Updated CHANGELOG and README with information about net_http_connect_…
authored Nov 2, 2010
670 * Alastair Brunton
e6af079 @bblimke Updated 1.6.2 changelog and credits
authored Jan 12, 2011
671 * Sam Stokes
672 * Eugene Bolshakov
7fd377b @bblimke Updated list of contributors in README
authored Aug 9, 2011
673 * James Conroy-Finn
674 * Salvador Fuentes Jr
675 * Alex Rothenberg
676 * Aidan Feldman
677 * Steve Hull
678 * Jay Adkisson
679 * Zach Dennis
680 * Nikita Fedyashev
681 * Lin Jen-Shin
b6ca337 @bblimke Version 1.7.4
authored Aug 18, 2011
682 * David Yeu
4d848df @bblimke Version 1.7.5
authored Aug 27, 2011
683 * Andreas Garnæs
748ff35 @bblimke Version 1.7.6
authored Sep 4, 2011
684 * Roman Shterenzon
4ff9f1a @bblimke Version 1.7.7 - RuPy 2011 Release
authored Oct 15, 2011
685 * Chris McGrath
686 * Stephen Celis
687 * Eugene Pimenov
4ff8cf1 @bblimke Version 1.7.9 changelog
authored Jan 4, 2012
688 * Albert Llop
689 * Christopher Pickslay
68ba906 @bblimke Updated Changelog and Readme with the latest changes in master
authored Feb 5, 2012
690 * Tammer Saleh
691 * Nicolas Fouché
692 * Joe Van Dyk
693 * Mark Abramov
694 * Frank Schumacher
695 * Dimitrij Denissenko
696 * Marnen Laibow-Koser
5cd5aaf @bblimke Fixed problem with body params being matched even if params were diff…
authored Feb 11, 2012
697 * Evgeniy Dolzhenko
00424d9 Updated credits in README
Bartosz Blimke authored Mar 26, 2010
698
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
699 For a full list of contributors you can visit the
700 [contributors](https://github.com/bblimke/webmock/contributors) page.
701
00424d9 Updated credits in README
Bartosz Blimke authored Mar 26, 2010
702 ## Background
703
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
704 Thank you Fakeweb! This library was inspired by [FakeWeb](fakeweb.rubyforge.org).
221e8cd @jcf Document setting up a WebMock development environment
jcf authored May 18, 2011
705 I imported some solutions from that project to WebMock. I also copied some code i.e Net:HTTP adapter.
95e8298 Revert "WebMock module has to be included manually and is not include…
Bartosz Blimke authored Nov 24, 2009
706 Fakeweb architecture unfortunately didn't allow me to extend it easily with the features I needed.
707 I also preferred some things to work differently i.e request stub precedence.
708
709 ## Copyright
710
bf18e89 Changed license from GPL to MIT
Bartosz Blimke authored May 24, 2010
711 Copyright (c) 2009-2010 Bartosz Blimke. See LICENSE for details.
Something went wrong with that request. Please try again.