Sha256: 1f6585eafa81e68a18d3409530d16740da48038400ee6a0dbd1087bb117b765c

Contents?: true

Size: 1.68 KB

Versions: 4

Compression:

Stored size: 1.68 KB

Contents

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

class Remote<%= class_name %>Test < Test::Unit::TestCase
  

  def setup
    @gateway = <%= class_name %>Gateway.new(fixtures(:<%= class_name.underscore %>))
    
    @amount = 100
    @credit_card = credit_card('4000100011112224')
    @declined_card = credit_card('4000300011112220')
    
    @options = { 
      :order_id => '1',
      :billing_address => address,
      :description => 'Store Purchase'
    }
  end
  
  def test_successful_purchase
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_success response
    assert_equal 'REPLACE WITH SUCCESS MESSAGE', response.message
  end

  def test_unsuccessful_purchase
    assert response = @gateway.purchase(@amount, @declined_card, @options)
    assert_failure response
    assert_equal 'REPLACE WITH FAILED PURCHASE MESSAGE', response.message
  end

  def test_authorize_and_capture
    amount = @amount
    assert auth = @gateway.authorize(amount, @credit_card, @options)
    assert_success auth
    assert_equal 'Success', auth.message
    assert auth.authorization
    assert capture = @gateway.capture(amount, auth.authorization)
    assert_success capture
  end

  def test_failed_capture
    assert response = @gateway.capture(@amount, '')
    assert_failure response
    assert_equal 'REPLACE WITH GATEWAY FAILURE MESSAGE', response.message
  end

  def test_invalid_login
    gateway = <%= class_name %>Gateway.new(
                :login => '',
                :password => ''
              )
    assert response = gateway.purchase(@amount, @credit_card, @options)
    assert_failure response
    assert_equal 'REPLACE WITH FAILURE MESSAGE', response.message
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
martinstannard-activemerchant-0.1.0 generators/gateway/templates/remote_gateway_test.rb
seamusabshere-active_merchant-1.4.2.1 generators/gateway/templates/remote_gateway_test.rb
seamusabshere-active_merchant-1.4.2.3 generators/gateway/templates/remote_gateway_test.rb
spree-0.2.0 vendor/plugins/active_merchant/generators/gateway/templates/remote_gateway_test.rb