Permalink
Browse files

Updated README with info about matching request body against hash

  • Loading branch information...
Bartosz Blimke
Bartosz Blimke committed Jun 19, 2010
1 parent 0d44535 commit fb18a017cbf2aeb77c66ea75861bbac5ae3ab6fb
Showing with 22 additions and 4 deletions.
  1. +22 −4 README.md
View
@@ -13,10 +13,13 @@ Features
* Smart matching of the same headers in different representations.
* Support for Test::Unit
* Support for RSpec 1.x and RSpec 2.x
-* Support for Net::HTTP and other http libraries based on Net::HTTP (i.e RightHttpConnection, rest-client, HTTParty)
-* Support for HTTPClient library (both sync and async requests)
-* Support for Patron library
-* Easy to extend to other HTTP libraries
+
+Supported HTTP libraries
+------------------------
+
+* Net::HTTP and libraries based on Net::HTTP (i.e RightHttpConnection, rest-client, HTTParty)
+* HTTPClient
+* Patron
Installation
------------
@@ -80,6 +83,20 @@ You can also use WebMock without RSpec or Test::Unit support:
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req, 'hello world')
} # ===> Success
+
+### Matching requests with URL-Encoded, JSON or XML body against hash
+
+ 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","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
@@ -463,6 +480,7 @@ People who submitted patches and new features or suggested improvements. Many th
* Jose Angel Cortinas
* Razic
* Steve Tooke
+* Nathaniel Bibler
## Background

0 comments on commit fb18a01

Please sign in to comment.