Sha256: ae5220039a8b6fedf83351abc672ae1b3de1c7573ea2ece52ced2e16c91cc0c4

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

require 'test/unit'
require File.dirname(__FILE__) + '/../../test_helper'

class PayJunctionTest < Test::Unit::TestCase
  include ActiveMerchant::Billing

  def setup
    
    ActiveMerchant::Billing::Base.gateway_mode = :test

    @gateway = PayJunctionGateway.new({
      :login      => "pj-ql-01",
      :password   => "pj-ql-01p"
    })

    @creditcard = CreditCard.new({
      :number => '4111111111111111',
      :month => 8,
      :year => 2006,
      :first_name => 'Longbob',
      :last_name => 'Longsen'
    })
    
  end

  def test_purchase_success    
    @creditcard.number = '1'
    
    assert response = @gateway.purchase(Money.new(100), @creditcard)
    assert_equal Response, response.class
    assert_equal '#0001', response.params['receiptid']
    assert_equal true, response.success?
  end

  def test_purchase_error
    @creditcard.number = '2'

    assert response = @gateway.purchase(Money.new(100), @creditcard)
    assert_equal Response, response.class
    assert_equal '#0001', response.params['receiptid']
    assert_equal false, response.success?

  end

  def test_purchase_exceptions
    @creditcard.number = '3' 

    assert_raise(Error) do
      assert response = @gateway.purchase(Money.new(100), @creditcard)  
    end
  end
   
  def test_amount_style   
   assert_equal '10.34', @gateway.send(:amount, Money.us_dollar(1034))
   assert_equal '10.34', @gateway.send(:amount, 1034)
                                                  
   assert_raise(ArgumentError) do
     @gateway.send(:amount, '10.34')
   end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activemerchant-1.2.0 test/unit/gateways/pay_junction_test.rb
activemerchant-1.2.1 test/unit/gateways/pay_junction_test.rb