Sha256: 163ff58e1bc01c4a3f3c6ad1374ced3e5e5d68486749b91de781dc2978d364cd

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Cardflex::ThreeStepGateway do
  it 'should raise an ArgumentError if no redirect_url' do
    expect do
      Cardflex::Configuration.gateway.three_step.get_form_url(:sale => { :test => 'test' })
    end.to raise_error(ArgumentError)
  end

  it 'should return a response with an error' do
    allow_any_instance_of(Cardflex::Http).to receive(:_do_http).and_return(
      SpecHelper::FakeResponse.new('<response><result>2</result></response>')
    )

    result = Cardflex::Configuration.gateway.three_step.get_form_url(:sale => { :test => 'test', :redirect_url => 'http://example.com' })
    expect(result.result).to eq 2
    expect(result.success?).to eq false
  end

  it 'should return a valid response' do
    allow_any_instance_of(Cardflex::Http).to receive(:_do_http).and_return(
      SpecHelper::FakeResponse.new("<response><result>1</result><form-url>http://test.com</form-url></response>")
    )

    result = Cardflex::Configuration.gateway.three_step.get_form_url(:sale => { :test => 'test', :redirect_url => 'http://example.com' })
    expect(result.three_step.form_url).to eq 'http://test.com'
    expect(result.success?).to eq true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cardflex-ruby-0.1.2 spec/unit/cardflex/three_step_gateway_spec.rb
cardflex-ruby-0.1.1 spec/unit/cardflex/three_step_gateway_spec.rb
cardflex-ruby-0.0.1 spec/unit/cardflex/three_step_gateway_spec.rb