Class: EWS::Transaction::FakeResponse
- Inherits:
-
Object
- Object
- EWS::Transaction::FakeResponse
- Defined in:
- lib/ews/transaction/fake_response.rb
Overview
As its name suggests, this class allows you to generate fake responses, allowing you to stub out the web service in your testing.
The most likely responses have been catered for here, but if you require a fake response which is not provided for here, the best approach would be to generate a fake valid response and then adjust its attributes (in consultation with E-xact’s Web Service Programming Reference Guide) to match the particular response you want.
Example:
describe "Fake requests" do
it "should stub sending" do
request = {:nonsense => "this is nonsense"}
fake_response = EWS::Transaction::FakeResponse.valid(request) # a fake valid response
transporter = EWS::Transporter.new
transporter.stubs(:submit).returns(fake_response)
response = transporter.submit(request)
response.should == fake_response
response.should be_approved
response..should == "APPROVED"
end
end
Class Method Summary collapse
-
.declined(request) ⇒ Object
fake a declined response.
-
.invalid_amount(request) ⇒ Object
fake a response indicating an invalid amount.
-
.invalid_auth_num(request) ⇒ Object
fake a response indicating an invalid authorisation number.
-
.invalid_avs(request) ⇒ Object
fake a response indicating an invalid address verification string.
-
.invalid_cardholder_name(request) ⇒ Object
fake a response indicating an invalid credit card holder name.
-
.invalid_cc_expiry(request) ⇒ Object
fake a response indicating an invalid credit card expiry date.
-
.invalid_cc_number(request) ⇒ Object
fake a response indicating an invalid credit card number.
-
.invalid_cc_verification_str(request) ⇒ Object
fake a response indicating an invalid credit card verification string.
-
.invalid_reference_no(request) ⇒ Object
fake a response indicating an invalid reference number.
-
.invalid_transaction_code(request) ⇒ Object
fake a response indicating an invalid transaction code.
-
.valid(request) ⇒ Object
fake a valid response.
Class Method Details
.declined(request) ⇒ Object
fake a declined response
34 35 36 |
# File 'lib/ews/transaction/fake_response.rb', line 34 def self.declined(request) response = build_response(request, {:bank_resp_code => '200'}) end |
.invalid_amount(request) ⇒ Object
fake a response indicating an invalid amount
47 48 49 |
# File 'lib/ews/transaction/fake_response.rb', line 47 def self.invalid_amount(request) build_response(request, {:exact_resp_code => '26'}) end |
.invalid_auth_num(request) ⇒ Object
fake a response indicating an invalid authorisation number
55 56 57 |
# File 'lib/ews/transaction/fake_response.rb', line 55 def self.invalid_auth_num(request) build_response(request, {:exact_resp_code => '28'}) end |
.invalid_avs(request) ⇒ Object
fake a response indicating an invalid address verification string
71 72 73 |
# File 'lib/ews/transaction/fake_response.rb', line 71 def self.invalid_avs(request) build_response(request, {:exact_resp_code => '58'}) end |
.invalid_cardholder_name(request) ⇒ Object
fake a response indicating an invalid credit card holder name
51 52 53 |
# File 'lib/ews/transaction/fake_response.rb', line 51 def self.invalid_cardholder_name(request) build_response(request, {:exact_resp_code => '27'}) end |
.invalid_cc_expiry(request) ⇒ Object
fake a response indicating an invalid credit card expiry date
43 44 45 |
# File 'lib/ews/transaction/fake_response.rb', line 43 def self.invalid_cc_expiry(request) build_response(request, {:exact_resp_code => '25'}) end |
.invalid_cc_number(request) ⇒ Object
fake a response indicating an invalid credit card number
39 40 41 |
# File 'lib/ews/transaction/fake_response.rb', line 39 def self.invalid_cc_number(request) build_response(request, {:exact_resp_code => '22'}) end |
.invalid_cc_verification_str(request) ⇒ Object
fake a response indicating an invalid credit card verification string
59 60 61 |
# File 'lib/ews/transaction/fake_response.rb', line 59 def self.invalid_cc_verification_str(request) build_response(request, {:exact_resp_code => '31'}) end |
.invalid_reference_no(request) ⇒ Object
fake a response indicating an invalid reference number
67 68 69 |
# File 'lib/ews/transaction/fake_response.rb', line 67 def self.invalid_reference_no(request) build_response(request, {:exact_resp_code => '57'}) end |
.invalid_transaction_code(request) ⇒ Object
fake a response indicating an invalid transaction code
63 64 65 |
# File 'lib/ews/transaction/fake_response.rb', line 63 def self.invalid_transaction_code(request) build_response(request, {:exact_resp_code => '32'}) end |
.valid(request) ⇒ Object
fake a valid response
30 31 32 |
# File 'lib/ews/transaction/fake_response.rb', line 30 def self.valid(request) build_response(request) end |