Class: Savon::Spec::Mock
- Inherits:
-
Object
- Object
- Savon::Spec::Mock
- Defined in:
- lib/savon/spec/mock.rb
Overview
Savon::Spec::Mock
Mocks/stubs SOAP requests executed by Savon.
Instance Method Summary collapse
-
#expects(soap_action) ⇒ Object
Mocks SOAP requests to a given
soap_action
. - #never ⇒ Object
-
#raises_soap_fault ⇒ Object
Sets up Savon to respond like there was a SOAP fault.
-
#returns(response = nil) ⇒ Object
Sets up HTTPI to return a given
response
. -
#stubs(soap_action) ⇒ Object
Stubs SOAP requests to a given
soap_action
. -
#with(soap_body) ⇒ Object
Expects a given SOAP body Hash to be used.
Instance Method Details
#expects(soap_action) ⇒ Object
Mocks SOAP requests to a given soap_action
.
12 13 14 15 |
# File 'lib/savon/spec/mock.rb', line 12 def expects(soap_action) setup :expects, soap_action self end |
#never ⇒ Object
29 30 31 32 |
# File 'lib/savon/spec/mock.rb', line 29 def never httpi_mock.never self end |
#raises_soap_fault ⇒ Object
Sets up Savon to respond like there was a SOAP fault.
49 50 51 52 |
# File 'lib/savon/spec/mock.rb', line 49 def raises_soap_fault Savon::SOAP::Response.any_instance.expects(:soap_fault?).returns(true) self end |
#returns(response = nil) ⇒ Object
Sets up HTTPI to return a given response
.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/savon/spec/mock.rb', line 35 def returns(response = nil) http = { :code => 200, :headers => {}, :body => "" } case response when Symbol then http[:body] = Fixture[soap_action, response] when Hash then http.merge! response when String then http[:body] = response end httpi_mock.returns HTTPI::Response.new(http[:code], http[:headers], http[:body]) self end |
#stubs(soap_action) ⇒ Object
Stubs SOAP requests to a given soap_action
.
18 19 20 21 |
# File 'lib/savon/spec/mock.rb', line 18 def stubs(soap_action) setup :stubs, soap_action self end |
#with(soap_body) ⇒ Object
Expects a given SOAP body Hash to be used.
24 25 26 27 |
# File 'lib/savon/spec/mock.rb', line 24 def with(soap_body) Savon::SOAP::XML.any_instance.expects(:body=).with(soap_body) if mock_method == :expects self end |