Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 114 lines (70 sloc) 4.293 kB
5313e02 Added version 0.9.0 features to CHANGELOG and README
Bartosz Blimke authored
1 #Changelog
2
3 ## 0.9.0
4
5 * Matching requests against provided block (by Sergio Gil)
6
7 stub_request(:post, "www.example.com").with { |request| request.body == "abc" }.to_return(:body => "def")
8 RestClient.post('www.example.com', 'abc') # ===> "def\n"
9 request(:post, "www.example.com").with { |req| req.body == "abc" }.should have_been_made
10 #or
11 assert_requested(:post, "www.example.com") { |req| req.body == "abc" }
12
13 * Matching request body against regular expressions
14
15 stub_request(:post, "www.example.com").with(:body => /^.*world$/).to_return(:body => "abc")
16 RestClient.post('www.example.com', 'hello world') # ===> "abc\n"
17
18 * Matching request headers against regular expressions
19
20 stub_request(:post, "www.example.com").with(:headers => {"Content-Type" => /image\/.+/}).to_return(:body => "abc")
21 RestClient.post('www.example.com', '', {'Content-Type' => 'image/png'}) # ===> "abc\n"
22
23 * Replaying raw responses recorded with `curl -is`
24
25 `curl -is www.example.com > /tmp/example_curl_-is_output.txt`
26 raw_response_file = File.new("/tmp/example_curl_-is_output.txt")
27
28 from file
29
30 stub_request(:get, "www.example.com").to_return(raw_response_file)
31
32 or string
33
34 stub_request(:get, "www.example.com").to_return(raw_response_file.read)
35
36 * Multiple responses for repeated requests
37
38 stub_request(:get, "www.example.com").to_return({:body => "abc"}, {:body => "def"})
39 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
40 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
41
42 * Multiple responses using chained `to_return()` or `to_raise()` declarations
43
44 stub_request(:get, "www.example.com").
45 to_return({:body => "abc"}).then. #then() just is a syntactic sugar
46 to_return({:body => "def"}).then.
47 to_raise(MyException)
48 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
49 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
50 Net::HTTP.get('www.example.com', '/') # ===> MyException raised
51
52 * Specifying number of times given response should be returned
53
54 stub_request(:get, "www.example.com").
55 to_return({:body => "abc"}).times(2).then.
56 to_return({:body => "def"})
57
58 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
59 Net::HTTP.get('www.example.com', '/') # ===> "abc\n"
60 Net::HTTP.get('www.example.com', '/') # ===> "def\n"
61
62 * Added support for `Net::HTTP::Post#body_stream`
63
64 This fixes compatibility with new versions of RestClient
65
66 * WebMock doesn't suppress default request headers added by http clients anymore.
67
68 i.e. Net::HTTP adds `'Accept'=>'*/*'` to all requests by default
69
70
71
72 ## 0.8.2
73
74 * Fixed issue where WebMock was not closing IO object passed as response body after reading it.
75 * 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
76
77
78 ## 0.8.1
79
80 * Fixed HTTPClient adapter compatibility with Ruby 1.8.6 (reported by Piotr Usewicz)
81 * Net:HTTP adapter now handles request body assigned as Net::HTTP::Post#body attribute (fixed by Mack Earnhardt)
82 * Fixed issue where requests were not matching stubs with Accept header set.(reported by Piotr Usewicz)
83 * Fixed compatibility with Ruby 1.9.1, 1.9.2 and JRuby 1.3.1 (reported by Diego E. “Flameeyes” Pettenò)
84 * Fixed issue with response body declared as IO object and multiple requests (reported by Niels Meersschaert)
85 * Fixed "undefined method `assertion_failure'" error (reported by Nick Plante)
86
87
88 ## 0.8.0
89
90 * Support for HTTPClient (sync and async requests)
91 * Support for dynamic responses. Response body and headers can be now declared as lambda.
92 (Thanks to Ivan Vega ( @ivanyv ) for suggesting this feature)
93 * Support for stubbing and expecting requests with empty body
94 * Executing non-stubbed request leads to failed expectation instead of error
95
96
97 ### Bug fixes
98
99 * Basic authentication now works correctly
100 * Fixed problem where WebMock didn't call a block with the response when block was provided
101 * Fixed problem where uris with single slash were not matching uris without path provided
102
103
104 ## 0.7.3
105
106 * Clarified documentation
107 * Fixed some issues with loading of Webmock classes
108 * Test::Unit and RSpec adapters have to be required separately
109
110
111 ## 0.7.2
112
113 * Added support for matching escaped and non escaped URLs
Something went wrong with that request. Please try again.