Skip to content

Commit

Permalink
Added specs to verify that all http client adapters work correctly wi…
Browse files Browse the repository at this point in the history
…th URIs with non empty path
  • Loading branch information
bblimke committed Nov 11, 2010
1 parent 9b4c3f8 commit 6d9f9a4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spec/webmock_shared.rb
Expand Up @@ -63,6 +63,11 @@ class MyException < StandardError; end;
stub_http_request(:get, "www.example.com").to_return(:body => "abc")
http_request(:get, "http://www.example.com/").body.should == "abc"
end

it "should return stubbed response if request with path was stubbed" do
stub_http_request(:get, "www.example.com/hello_world").to_return(:body => "abc")
http_request(:get, "http://www.example.com/hello_world").body.should == "abc"
end

it "should raise exception if request was not stubbed" do
lambda {
Expand Down Expand Up @@ -133,18 +138,18 @@ class MyException < StandardError; end;
describe "on uri" do

it "should match the request by uri with non escaped params if request have escaped parameters" do
stub_http_request(:get, "www.example.com/?#{NOT_ESCAPED_PARAMS}").to_return(:body => "abc")
http_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}").body.should == "abc"
stub_http_request(:get, "www.example.com/hello/?#{NOT_ESCAPED_PARAMS}").to_return(:body => "abc")
http_request(:get, "http://www.example.com/hello/?#{ESCAPED_PARAMS}").body.should == "abc"
end

it "should match the request by uri with escaped parameters even if request has non escaped params" do
stub_http_request(:get, "www.example.com/?#{ESCAPED_PARAMS}").to_return(:body => "abc")
http_request(:get, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}").body.should == "abc"
stub_http_request(:get, "www.example.com/hello/?#{ESCAPED_PARAMS}").to_return(:body => "abc")
http_request(:get, "http://www.example.com/hello/?#{NOT_ESCAPED_PARAMS}").body.should == "abc"
end

it "should match the request by regexp matching non escaped params uri if request params are escaped" do
stub_http_request(:get, /.*x=ab c.*/).to_return(:body => "abc")
http_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}").body.should == "abc"
http_request(:get, "http://www.example.com/hello/?#{ESCAPED_PARAMS}").body.should == "abc"
end

end
Expand Down

0 comments on commit 6d9f9a4

Please sign in to comment.