Sha256: 9b738f8962a3957bfb7e69c2c9f5a6286e8f72454171c9e2408d6b8e422485ba
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') # Unfortunately, there is no testing account for the query API. Stub it instead describe Cardflex::Transaction do it 'should raise an argument error if no username/password supplied' do expect do Cardflex::Transaction.query(:transaction_id => 1) end.to raise_error(ArgumentError) end it 'should fail to query the cardflex api' do allow_any_instance_of(Cardflex::Http).to receive(:_do_http).and_return( SpecHelper::FakeResponse.new("<nm_response><error_response>failure</error_response></nm_response>") ) Cardflex::Configuration.username = "demo" Cardflex::Configuration.password = "password" result = Cardflex::Transaction.query(:transaction_id => 1) expect(result.success?).to be false expect(result.result_text).to eq "failure" end it 'should query the cardflex api' do allow_any_instance_of(Cardflex::Http).to receive(:_do_http).and_return( SpecHelper::FakeResponse.new("<nm_response><transaction><transaction_id>1</transaction_id></transaction></nm_response>") ) Cardflex::Configuration.username = "demo" Cardflex::Configuration.password = "password" result = Cardflex::Transaction.query(:transaction_id => 1) expect(result.success?).to be true expect(result.transaction.transaction_id.to_i).to eq 1 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cardflex-ruby-0.1.2 | spec/integration/cardflex/query_spec.rb |
cardflex-ruby-0.1.1 | spec/integration/cardflex/query_spec.rb |