Sha256: a4c30e83385269bbade1b2aa345891751c7e14df19907c9756428bd8c371a119

Contents?: true

Size: 1.71 KB

Versions: 34

Compression:

Stored size: 1.71 KB

Contents

require 'test_helper'

class RemoteInstapayTest < Test::Unit::TestCase
  
  def setup
    @gateway = InstapayGateway.new(fixtures(:instapay))

    @amount = 100
    @credit_card = credit_card('5454545454545454')
    @declined_card = credit_card('4000300011112220')

    @options = {
      :order_id => generate_unique_id,
      :billing_address => address,
      :shipping_address => address,
      :description => 'Store Purchase'
    }
  end

  def test_successful_purchase
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_success response
    assert_equal InstapayGateway::SUCCESS_MESSAGE, response.message
  end

  def test_failed_purchase
    assert response = @gateway.purchase(@amount,  @declined_card, @options)
    assert_failure response
  end

  def test_succesful_authorization
    assert response = @gateway.authorize(@amount,  @credit_card, @options)
    assert_success response
    assert_equal InstapayGateway::SUCCESS_MESSAGE, response.message
  end

  def test_failed_authorization
    assert response = @gateway.authorize(@amount,  @declined_card, @options)
    assert_failure response
  end
  
  def test_authorization_and_capture
    assert authorization = @gateway.authorize(@amount, @credit_card, @options)
    assert_success authorization
  
    assert capture = @gateway.capture(@amount, authorization.authorization)
    assert_success capture
    assert_equal InstapayGateway::SUCCESS_MESSAGE, capture.message
  end
  
  def test_invalid_login
    gateway = InstapayGateway.new(
      :login => 'X',
      :password => 'Y'
    )
    
    assert response = gateway.purchase(@amount, @credit_card)
    assert_failure response
    assert_equal "Invalid merchant", response.message
  end
end

Version data entries

34 entries across 34 versions & 11 rubygems

Version Path
johnideal-activemerchant-1.4.10 test/remote/gateways/remote_instapay_test.rb
johnideal-activemerchant-1.4.11 test/remote/gateways/remote_instapay_test.rb
johnideal-activemerchant-1.4.4 test/remote/gateways/remote_instapay_test.rb
johnideal-activemerchant-1.4.5 test/remote/gateways/remote_instapay_test.rb
johnideal-activemerchant-1.4.6 test/remote/gateways/remote_instapay_test.rb
johnideal-activemerchant-1.4.7 test/remote/gateways/remote_instapay_test.rb
johnideal-activemerchant-1.4.8 test/remote/gateways/remote_instapay_test.rb
mattbauer-activemerchant-1.4.2 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.3 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.4 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.5 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.6 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.7 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.8 test/remote/gateways/remote_instapay_test.rb
tomriley-tomriley-active_merchant-1.4.2.4 test/remote/gateways/remote_instapay_test.rb
goldstar-activemerchant-1.4.2.7 test/remote/gateways/remote_instapay_test.rb
goldstar-activemerchant-1.4.2.6 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.11 test/remote/gateways/remote_instapay_test.rb
tomriley-active_merchant-1.4.2.10 test/remote/gateways/remote_instapay_test.rb
smulube-activemerchant-1.5.1.4 test/remote/gateways/remote_instapay_test.rb