Skip to content

Commit

Permalink
Changed all specs where WebMock is matching request body to use POST …
Browse files Browse the repository at this point in the history
…requests.
  • Loading branch information
Bartosz Blimke committed Jan 31, 2010
1 parent 3e0fa6e commit e4d5d7b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/webmock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,42 +101,42 @@ class MyException < StandardError; end;
describe "on body" do

it "should match requests if body is the same" do
stub_http_request(:get, "www.example.com").with(:body => "abc")
stub_http_request(:post, "www.example.com").with(:body => "abc")
http_request(
:get, "http://www.example.com/",
:post, "http://www.example.com/",
:body => "abc").status.should == "200"
end

it "should match requests if body is not set in the stub" do
stub_http_request(:get, "www.example.com")
stub_http_request(:post, "www.example.com")
http_request(
:get, "http://www.example.com/",
:post, "http://www.example.com/",
:body => "abc").status.should == "200"
end

it "should not match requests if body is different" do
stub_http_request(:get, "www.example.com").with(:body => "abc")
stub_http_request(:post, "www.example.com").with(:body => "abc")
lambda {
http_request(:get, "http://www.example.com/", :body => "def")
http_request(:post, "http://www.example.com/", :body => "def")
}.should fail_with(client_specific_request_string(
"Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with body 'def'"))
"Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'def'"))
end

describe "with regular expressions" do

it "should match requests if body matches regexp" do
stub_http_request(:get, "www.example.com").with(:body => /\d+abc$/)
stub_http_request(:post, "www.example.com").with(:body => /\d+abc$/)
http_request(
:get, "http://www.example.com/",
:post, "http://www.example.com/",
:body => "123abc").status.should == "200"
end

it "should not match requests if body doesn't match regexp" do
stub_http_request(:get, "www.example.com").with(:body => /^abc/)
stub_http_request(:post, "www.example.com").with(:body => /^abc/)
lambda {
http_request(:get, "http://www.example.com/", :body => "xabc")
http_request(:post, "http://www.example.com/", :body => "xabc")
}.should fail_with(client_specific_request_string(
"Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with body 'xabc'"))
"Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'xabc'"))
end

end
Expand Down

0 comments on commit e4d5d7b

Please sign in to comment.