Skip to content

HTTPS clone URL

Subversion checkout URL

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