Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 255 lines (148 sloc) 9.443 kB
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
1 #Changelog
2
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored
3 ## 1.3.0
4
5 * Added support for [em-http-request](http://github.com/igrigorik/em-http-request)
6
7 * Matching query params using a hash
8
9 stub_http_request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]})
10
11 RestClient.get("http://www.example.com/?a[]=b&a[]=c") # ===> Success
12
13 request(:get, "www.example.com").with(:query => {"a" => ["b", "c"]}).should have_been_made # ===> Success
14
15 * Matching request body against a hash. Body can be URL-Encoded, JSON or XML.
26cb92f Small improvements to CHANGELOG for version 1.3.0
Bartosz Blimke authored
16
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored
17 (Thanks to Steve Tooke for the idea and a solution for url-encoded bodies)
18
19 stub_http_request(:post, "www.example.com").
20 with(:body => {:data => {:a => '1', :b => 'five'}})
21
22 RestClient.post('www.example.com', "data[a]=1&data[b]=five",
23 :content_type => 'application/x-www-form-urlencoded') # ===> Success
24
25 RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
26 :content_type => 'application/json') # ===> Success
27
28 RestClient.post('www.example.com', '<data a="1" b="five" />',
29 :content_type => 'application/xml' ) # ===> Success
30
31 request(:post, "www.example.com").
32 with(:body => {:data => {:a => '1', :b => 'five'}},
33 :headers => 'Content-Type' => 'application/json').should have_been_made # ===> Success
34
35 * Request callbacks (Thanks to Myron Marston for all suggestions)
36
37 WebMock can now invoke callbacks for stubbed or real requests:
38
39 WebMock.after_request do |request_signature, response|
40 puts "Request #{request_signature} was made and #{response} was returned"
41 end
42
43 invoke callbacks for real requests only and except requests made with Patron client
44
45 WebMock.after_request(:except => [:patron], :real_requests_only => true) do |request_signature, response|
46 puts "Request #{request_signature} was made and #{response} was returned"
47 end
48
49 * `to_raise()` now accepts an exception instance or a string as argument in addition to an exception class
50
51 stub_request(:any, 'www.example.net').to_raise(StandardError.new("some error"))
52
53 stub_request(:any, 'www.example.net').to_raise("some error")
54
26cb92f Small improvements to CHANGELOG for version 1.3.0
Bartosz Blimke authored
55 * Matching requests based on a URI is 30% faster
354af66 Updated CHANGELOG width version 1.3.0 changes
Bartosz Blimke authored
56
57 * Fixed constant namespace issues in HTTPClient adapter. Thanks to Nathaniel Bibler for submitting a patch.
58
fd2472a Version 1.2.2 changelog
Bartosz Blimke authored
59 ## 1.2.2
60
61 * Fixed problem where ArgumentError was raised if query params were made up of an array e.g. data[]=a&data[]=b. Thanks to Steve Tooke
62
5803f31 Version bump to 1.2.1
Bartosz Blimke authored
63 ## 1.2.1
64
65 * Changed license from GPL to MIT
66
67 * Fixed gemspec file. Thanks to Razic
68
31b3ffb Added version 1.2.0 changelog
Bartosz Blimke authored
69 ## 1.2.0
70
71 * RSpec 2 compatibility. Thanks to Sam Phillips!
72
73 * :allow_localhost => true' now permits 127.0.0.1 as well as 'localhost'. Thanks to Mack Earnhardt
74
75 * Request URI matching in now 2x faster!
76
77
4a04017 Added 1.1.0 changelog
Bartosz Blimke authored
78 ## 1.1.0
79
ee7b3b4 Fixed spelling
Bartosz Blimke authored
80 * [VCR](http://github.com/myronmarston/vcr/) compatibility. Many thanks to Myron Marston for all suggestions.
4a04017 Added 1.1.0 changelog
Bartosz Blimke authored
81
82 * Support for stubbing requests and returning responses with multiple headers with the same name. i.e multiple Accept headers.
83
84 stub_http_request(:get, 'www.example.com').
85 with(:headers => {'Accept' => ['image/png', 'image/jpeg']}).
86 to_return(:body => 'abc')
87 RestClient.get('www.example.com',
88 {"Accept" => ['image/png', 'image/jpeg']}) # ===> "abc\n"
89
90 * When real net connections are disabled and unstubbed request is made, WebMock throws WebMock::NetConnectNotAllowedError instead of assertion error or StandardError.
91
92 * Added WebMock.version()
93
94
66519c1 Updated changelog with 1.0.0 changes
Bartosz Blimke authored
95 ## 1.0.0
96
97 * Added support for [Patron](http://toland.github.com/patron/)
98
99 * Responses dynamically evaluated from block (idea and implementation by Tom Ward)
100
101 stub_request(:any, 'www.example.net').
102 to_return { |request| {:body => request.body} }
103
104 RestClient.post('www.example.net', 'abc') # ===> "abc\n"
105
106 * Responses dynamically evaluated from lambda (idea and implementation by Tom Ward)
107
108 stub_request(:any, 'www.example.net').
109 to_return(lambda { |request| {:body => request.body} })
110
111 RestClient.post('www.example.net', 'abc') # ===> "abc\n"
112
113 * Response with custom status message
114
115 stub_request(:any, "www.example.com").to_return(:status => [500, "Internal Server Error"])
116
117 req = Net::HTTP::Get.new("/")
118 Net::HTTP.start("www.example.com") { |http| http.request(req) }.message # ===> "Internal Server Error"
119
c3c92ba Added information about allowing localhost to version 1.0.0 changelog
Bartosz Blimke authored
120 * Raising timeout errors (suggested by Jeffrey Jones) (compatibility with Ruby 1.8.6 by Mack Earnhardt)
66519c1 Updated changelog with 1.0.0 changes
Bartosz Blimke authored
121
122 stub_request(:any, 'www.example.net').to_timeout
123
124 RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
125
c3c92ba Added information about allowing localhost to version 1.0.0 changelog
Bartosz Blimke authored
126 * External requests can be disabled while allowing localhost (idea and implementation by Mack Earnhardt)
127
128 WebMock.disable_net_connect!(:allow_localhost => true)
129
130 Net::HTTP.get('www.something.com', '/') # ===> Failure
131
132 Net::HTTP.get('localhost:9887', '/') # ===> Allowed. Perhaps to Selenium?
133
134
66519c1 Updated changelog with 1.0.0 changes
Bartosz Blimke authored
135 ### Bug fixes
136
137 * Fixed issue where Net::HTTP adapter didn't work for requests with body responding to read (reported by Tekin Suleyman)
c3c92ba Added information about allowing localhost to version 1.0.0 changelog
Bartosz Blimke authored
138 * Fixed issue where request stub with headers declared as nil was matching requests with non empty headers
66519c1 Updated changelog with 1.0.0 changes
Bartosz Blimke authored
139
b6c3b3b Version bump to 0.9.1
Bartosz Blimke authored
140 ## 0.9.1
141
142 * Fixed issue where response status code was not read from raw (curl -is) responses
143
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
144 ## 0.9.0
145
146 * Matching requests against provided block (by Sergio Gil)
147
148 stub_request(:post, "www.example.com").with { |request| request.body == "abc" }.to_return(:body => "def")
149 RestClient.post('www.example.com', 'abc') # ===> "def\n"
150 request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
151 #or
152 assert_requested(:post, "www.example.com") { |req| req.body == "abc" }
153
66519c1 Updated changelog with 1.0.0 changes
Bartosz Blimke authored
154 * Matching request body against regular expressions (suggested by Ben Pickles)
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
155
156 stub_request(:post, "www.example.com").with(:body => /^.*world$/).to_return(:body => "abc")
157 RestClient.post('www.example.com', 'hello world') # ===> "abc\n"
158
66519c1 Updated changelog with 1.0.0 changes
Bartosz Blimke authored
159 * Matching request headers against regular expressions (suggested by Ben Pickles)
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
160
161 stub_request(:post, "www.example.com").with(:headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
162 RestClient.post('www.example.com', '', {'Content-Type' => 'image/png'}) # ===> "abc\n"
163
164 * Replaying raw responses recorded with `curl -is`
165
166 `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
167 raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
168
c2648fc Fixed formatting in 0.9.0 changelog
Bartosz Blimke authored
169 from file
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
170
171 stub_request(:get, "www.example.com").to_return(raw_response_file)
172
c2648fc Fixed formatting in 0.9.0 changelog
Bartosz Blimke authored
173 or string
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
174
175 stub_request(:get, "www.example.com").to_return(raw_response_file.read)
176
177 * Multiple responses for repeated requests
178
179 stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
180 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
181 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
182
183 * Multiple responses using chained `to_return()` or `to_raise()` declarations
184
185 stub_request(:get, "www.example.com").
186 to_return({:body => "abc"}).then. #then() just is a syntactic sugar
187 to_return({:body => "def"}).then.
188 to_raise(MyException)
189 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
190 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
191 Net::HTTP.get('www.example.com', '/') # ===> MyException raised
192
193 * Specifying number of times given response should be returned
194
195 stub_request(:get, "www.example.com").
196 to_return({:body => "abc"}).times(2).then.
197 to_return({:body => "def"})
198
199 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
200 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
201 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
202
203 * Added support for `Net::HTTP::Post#body_stream`
204
c2648fc Fixed formatting in 0.9.0 changelog
Bartosz Blimke authored
205 This fixes compatibility with new versions of RestClient
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
206
207 * WebMock doesn't suppress default request headers added by http clients anymore.
208
c2648fc Fixed formatting in 0.9.0 changelog
Bartosz Blimke authored
209 i.e. Net::HTTP adds `'Accept'=>'*/*'` to all requests by default
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
210
211
212
213 ## 0.8.2
214
215 * Fixed issue where WebMock was not closing IO object passed as response body after reading it.
216 * Ruby 1.9.2 compat: Use `File#expand_path` for require path because "." is not be included in LOAD_PATH since Ruby 1.9.2
217
218
219 ## 0.8.1
220
221 * Fixed HTTPClient adapter compatibility with Ruby 1.8.6 (reported by Piotr Usewicz)
222 * Net:HTTP adapter now handles request body assigned as Net::HTTP::Post#body attribute (fixed by Mack Earnhardt)
223 * Fixed issue where requests were not matching stubs with Accept header set.(reported by Piotr Usewicz)
224 * Fixed compatibility with Ruby 1.9.1, 1.9.2 and JRuby 1.3.1 (reported by Diego E. “Flameeyes” Pettenò)
225 * Fixed issue with response body declared as IO object and multiple requests (reported by Niels Meersschaert)
226 * Fixed "undefined method `assertion_failure'" error (reported by Nick Plante)
227
228
229 ## 0.8.0
230
231 * Support for HTTPClient (sync and async requests)
232 * Support for dynamic responses. Response body and headers can be now declared as lambda.
233 (Thanks to Ivan Vega ( @ivanyv ) for suggesting this feature)
234 * Support for stubbing and expecting requests with empty body
235 * Executing non-stubbed request leads to failed expectation instead of error
236
237
238 ### Bug fixes
239
240 * Basic authentication now works correctly
241 * Fixed problem where WebMock didn't call a block with the response when block was provided
242 * Fixed problem where uris with single slash were not matching uris without path provided
243
244
245 ## 0.7.3
246
247 * Clarified documentation
248 * Fixed some issues with loading of Webmock classes
249 * Test::Unit and RSpec adapters have to be required separately
250
251
252 ## 0.7.2
253
254 * Added support for matching escaped and non escaped URLs
Something went wrong with that request. Please try again.