require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Cardflex::CustomerVault do it 'should pass step 1 (customer vault)' do res = Cardflex::ThreeStep.add_customer(:redirect_url => "http://example.com") expect(res.success?).to be true expect(res.three_step.form_url).to match('secure.cardflexonline.com') end it 'should complete the operation (customer vault)' do form_url = Cardflex::ThreeStep.add_customer(:redirect_url => 'http://example.com').three_step.form_url token_id = SpecHelper.step_two(form_url) res = Cardflex::ThreeStep.complete(token_id) expect(res.success?).to be true expect(res.transaction.customer_vault_id).to_not be nil end it 'should pass step 1 (subscription)' do # ensure a plan exists. this assumes the Plan code works, check there first if errors arise req = { :plan => { :payments => 0, :amount => 1.5, :name => 'test_plan', :plan_id => 1, :day_frequency => 30 } } Cardflex::Plan.create(req) res = Cardflex::ThreeStep.add_subscription({ :redirect_url => 'http://example.com', :plan => { :plan_id => 1 }}) expect(res.success?).to be true expect(res.three_step.form_url).to match('secure.cardflexonline.com') end end