Class: WsdlMapperTesting::StubConnection
- Inherits:
-
Faraday::Connection
- Object
- Faraday::Connection
- WsdlMapperTesting::StubConnection
- Defined in:
- lib/wsdl_mapper_testing/stub_connection.rb
Instance Attribute Summary collapse
-
#stubs ⇒ Object
readonly
Returns the value of attribute stubs.
Instance Method Summary collapse
-
#initialize ⇒ StubConnection
constructor
A new instance of StubConnection.
- #stub_action(url, action, body) ⇒ Object
- #stub_error(url, error) ⇒ Object
- #stub_post(url, body) ⇒ Object
- #stub_request(url, request, body) ⇒ Object
Constructor Details
#initialize ⇒ StubConnection
Returns a new instance of StubConnection.
7 8 9 10 11 12 13 14 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 7 def initialize @stubs = Faraday::Adapter::Test::Stubs.new @actions = {} @requests = {} super do adapter :test, @stubs end end |
Instance Attribute Details
#stubs ⇒ Object (readonly)
Returns the value of attribute stubs.
5 6 7 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 5 def stubs @stubs end |
Instance Method Details
#stub_action(url, action, body) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 22 def stub_action(url, action, body) hsh = @actions[url] unless hsh hsh = @actions[url] = {} @stubs.post url do |env| req_action = env.request_headers['SOAPAction'] [200, {}, hsh[req_action]] end end hsh[action] = body end |
#stub_error(url, error) ⇒ Object
46 47 48 49 50 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 46 def stub_error(url, error) @stubs.post url do |_| raise error end end |
#stub_post(url, body) ⇒ Object
16 17 18 19 20 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 16 def stub_post(url, body) @stubs.post url do [200, {}, body] end end |
#stub_request(url, request, body) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 34 def stub_request(url, request, body) hsh = @requests[url] unless hsh hsh = @requests[url] = {} @stubs.post url do |env| req_request = env.body [200, {}, hsh[req_request]] end end hsh[request] = body end |