Class: WsdlMapperTesting::StubConnection
- Inherits:
-
Faraday::Connection
- Object
- Faraday::Connection
- WsdlMapperTesting::StubConnection
- Defined in:
- lib/wsdl_mapper_testing/stub_connection.rb
Instance Attribute Summary (collapse)
-
- (Object) stubs
readonly
Returns the value of attribute stubs.
Instance Method Summary (collapse)
-
- (StubConnection) initialize
constructor
A new instance of StubConnection.
- - (Object) stub_action(url, action, body)
- - (Object) stub_error(url, error)
- - (Object) stub_post(url, body)
- - (Object) stub_request(url, request, body)
Constructor Details
- (StubConnection) initialize
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
- (Object) stubs (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
- (Object) stub_action(url, action, body)
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 |
- (Object) stub_error(url, error)
46 47 48 49 50 |
# File 'lib/wsdl_mapper_testing/stub_connection.rb', line 46 def stub_error(url, error) @stubs.post url do |env| raise error end end |
- (Object) stub_post(url, body)
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 |
- (Object) stub_request(url, request, body)
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 |