Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from zrivest/add_support_for_patch_http_method
Add support for PATCH http method
- Loading branch information
Showing
3 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'teststrap' | ||
|
||
context "Sending a PATCH request with a base uri" do | ||
|
||
context "without params" do | ||
hookup do | ||
stub_request(:patch, 'http://test.local/foo') | ||
.with(:body => {"foo" => "bar"}.to_json) | ||
.to_return(:body => "Foo", :status => 200) | ||
end | ||
|
||
base_uri "http://test.local" | ||
patch "/foo", :body => {"foo" => "bar"}.to_json | ||
|
||
asserts("status code") { response.code }.equals(200) | ||
asserts("response body") { response.body }.equals("Foo") | ||
end # without params | ||
|
||
context "with params" do | ||
hookup do | ||
stub_request(:patch, 'http://test.local/foo?bar=baz'). | ||
with(:body => {"goo" => "car"}.to_json). | ||
to_return(:body => "", :status => 203) | ||
end | ||
|
||
context "through default_params" do | ||
base_uri "http://test.local" | ||
default_params({"bar" => "baz"}) | ||
patch "/foo", :body => {"goo" => "car"}.to_json | ||
|
||
asserts("status code") { response.code }.equals(203) | ||
end # through default_params | ||
|
||
context "through query string" do | ||
base_uri "http://test.local" | ||
patch "/foo?bar=baz", :body => {"goo" => "car"}.to_json | ||
|
||
asserts("status code") { response.code }.equals(203) | ||
end # through query string | ||
end # with params | ||
|
||
context "while processing options from a block" do | ||
hookup do | ||
stub_request(:patch, 'http://test.local/foo/bar'). | ||
with(:body => {"s" => "things"}.to_json). | ||
to_return(:body => "", :status => 299) | ||
end | ||
|
||
base_uri "http://test.local" | ||
|
||
patch do | ||
{ :path => "/foo/bar", :body => {"s" => "things"}.to_json } | ||
end | ||
|
||
asserts("status code") { response.code }.equals(299) | ||
end # while processing options from a block | ||
|
||
end # Sending a PUT request with a base uri |