module Adyen::API::PaymentService::TestHelpers

A collection of test helpers that create and assign stubbed response instances for a subsequent remote call.

This module extends the {PaymentService} class and thus these methods are callable on it.

Constants

AUTHORISATION_REFUSED_RESPONSE
AUTHORISATION_REQUEST_INVALID_RESPONSE
AUTHORISE_RESPONSE

Public Instance Methods

invalid_stub() click to toggle source

@return [AuthorisationResponse] An ‘invalid request’ response instance.

   # File lib/adyen/api/test_helpers.rb
69 def invalid_stub
70   http_response = Net::HTTPOK.new('1.1', '200', 'OK')
71   def http_response.body; AUTHORISATION_REQUEST_INVALID_RESPONSE; end
72   PaymentService::AuthorisationResponse.new(http_response)
73 end
refused_stub() click to toggle source

@return [AuthorisationResponse] An authorisation refused response instance.

   # File lib/adyen/api/test_helpers.rb
62 def refused_stub
63   http_response = Net::HTTPOK.new('1.1', '200', 'OK')
64   def http_response.body; AUTHORISATION_REFUSED_RESPONSE; end
65   PaymentService::AuthorisationResponse.new(http_response)
66 end
stub_invalid!() click to toggle source

Assigns a {#invalid_stub}, meaning the subsequent authoristaion request will be refused, because the request was invalid.

@return [AuthorisationResponse] An ‘invalid request’ response instance.

   # File lib/adyen/api/test_helpers.rb
93 def stub_invalid!
94   @stubbed_response = invalid_stub
95 end
stub_refused!() click to toggle source

Assigns a {#refused_stub}, meaning the subsequent authoristaion request will be refused.

@return [AuthorisationResponse] An authorisation refused response instance.

   # File lib/adyen/api/test_helpers.rb
85 def stub_refused!
86   @stubbed_response = refused_stub
87 end
stub_success!() click to toggle source

Assigns a {#success_stub}, meaning the subsequent authoristaion request will be authorised.

@return [AuthorisationResponse] A authorisation succeeded response instance.

   # File lib/adyen/api/test_helpers.rb
78 def stub_success!
79   @stubbed_response = success_stub
80 end
success_stub() click to toggle source

@return [AuthorisationResponse] A authorisation succeeded response instance.

   # File lib/adyen/api/test_helpers.rb
55 def success_stub
56   http_response = Net::HTTPOK.new('1.1', '200', 'OK')
57   def http_response.body; AUTHORISE_RESPONSE; end
58   PaymentService::AuthorisationResponse.new(http_response)
59 end