require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Cardflex::ThreeStepGateway do it 'should fail step 1 in testing env (missing amount)' do res = Cardflex::Configuration.gateway.three_step.get_form_url({ :sale => { :redirect_url => 'http://example.com' } }) expect(res.success?).to eq false end it 'should pass step 1 in testing env' do res = Cardflex::Configuration.gateway.three_step.get_form_url({ :sale => { :redirect_url => 'http://example.com', :amount => 1.5 } }) expect(res.success?).to eq true expect(res.three_step.form_url).to match "secure.cardflexonline.com" end it 'should complete a transaction in testing env' do res = Cardflex::Configuration.gateway.three_step.get_form_url({ :sale => { :redirect_url => 'http://example.com', :amount => 1.5 } }) form_url = res.three_step.form_url token_id = SpecHelper.step_two(form_url) complete_result = Cardflex::Configuration.gateway.three_step.complete(token_id) expect(complete_result.success?).to be true expect(complete_result.transaction.transaction_id).to_not be nil end it 'should decline a transaction in testing env' do res = Cardflex::Configuration.gateway.three_step.get_form_url({ :sale => { :redirect_url => 'http://example.com', :amount => 0.5 } }) form_url = res.three_step.form_url token_id = SpecHelper.step_two(form_url) res = Cardflex::Configuration.gateway.three_step.complete(token_id) expect(res.success?).to be false expect(res.result_code.to_i).to eq 200 end end