From a6c7008aca6ac3a4315dd5065aa563704d5d0a11 Mon Sep 17 00:00:00 2001 From: Thomas Jachmann Date: Tue, 8 Feb 2011 17:21:34 +0100 Subject: [PATCH] adds never --- lib/savon/spec/mock.rb | 5 +++++ spec/savon/spec/mock_spec.rb | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/savon/spec/mock.rb b/lib/savon/spec/mock.rb index f253c15..6a903e4 100644 --- a/lib/savon/spec/mock.rb +++ b/lib/savon/spec/mock.rb @@ -26,6 +26,11 @@ def with(soap_body) self end + def never + httpi_mock.never + self + end + # Sets up HTTPI to return a given +response+. def returns(response = nil) http = { :code => 200, :headers => {}, :body => "" } diff --git a/spec/savon/spec/mock_spec.rb b/spec/savon/spec/mock_spec.rb index cf914d7..1aaf709 100644 --- a/spec/savon/spec/mock_spec.rb +++ b/spec/savon/spec/mock_spec.rb @@ -47,7 +47,20 @@ Mocha::ExpectationError, /expected exactly once, not yet invoked: #.body=\(:id => 1\)/ ) - + + teardown_mocks_for_rspec + end + end + + describe "#expects and #never" do + before { savon.expects(:noop).never } + + it "should not expect Savon to send a given SOAP body" do + expect { client.request(:noop) }.to raise_error( + Mocha::ExpectationError, + /expected never, invoked once: HTTPI.post()/ + ) + teardown_mocks_for_rspec end end