Permalink
Browse files

fixed assertion problem

only parts of the SOAP input tag were matched.
  • Loading branch information...
1 parent b9a02db commit 280e8e5b68db6cc3b3773c5681fb7adee9ba6b91 @rubiii rubiii committed Apr 26, 2011
Showing with 16 additions and 7 deletions.
  1. +1 −1 lib/savon/spec/mock.rb
  2. +15 −6 spec/savon/spec/mock_spec.rb
@@ -68,7 +68,7 @@ def soap_action=(soap_action)
attr_reader :soap_action
def new_httpi_mock
- HTTPI.send(mock_method, :post).with { |http| http.body.include? soap_action }
+ HTTPI.send(mock_method, :post).with { |http| http.body =~ /<\/(.+:)?#{soap_action}>/ }
end
attr_accessor :httpi_mock
@@ -21,12 +21,21 @@
client.request :get_user
end
+ it "should fail when only parts of the SOAP action matched" do
+ expect { client.request :get_user_by_id }.to raise_error(
+ Mocha::ExpectationError,
+ /expected exactly once, not yet invoked: HTTPI.post/
+ )
+
+ teardown_mocks_for_rspec
+ end
+
it "should fail when no SOAP call was made" do
expect { verify_mocks_for_rspec }.to raise_error(
Mocha::ExpectationError,
/expected exactly once, not yet invoked: HTTPI.post/
)
-
+
teardown_mocks_for_rspec
end
end
@@ -42,7 +51,7 @@
it "should fail when the SOAP body was not send" do
client.request(:get_user)
-
+
expect { verify_mocks_for_rspec }.to raise_error(
Mocha::ExpectationError,
/expected exactly once, not yet invoked: #<AnyInstance:Savon::SOAP::XML>.body=\(:id => 1\)/
@@ -129,9 +138,9 @@
around do |example|
Savon::Spec::Fixture.path = "spec/fixtures"
savon.expects(:get_user).returns(:success)
-
+
example.run
-
+
Savon::Spec::Fixture.path = nil # reset to default
end
@@ -179,10 +188,10 @@
it "should just act like there was a SOAP fault if raising errors was disabled" do
Savon.raise_errors = false
-
+
response = client.request :get_user
response.should be_a_soap_fault
-
+
Savon.raise_errors = true # reset to default
end
end

0 comments on commit 280e8e5

Please sign in to comment.