Sha256: c4fb07b6ba42a06f440d1e198b0134c8bbc47841039e0cd20363b57e84729530

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class <%= class_name %>Test < Test::Unit::TestCase
  def setup
    @gateway = <%= class_name %>Gateway.new(
                 :login => 'login',
                 :password => 'password'
               )

    @credit_card = credit_card
    @amount = 100
    
    @options = { 
      :order_id => '1',
      :billing_address => address,
      :description => 'Store Purchase'
    }
  end
  
  def test_successful_purchase
    @gateway.expects(:ssl_post).returns(successful_purchase_response)
    
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_instance_of 
    assert_success response
    
    # Replace with authorization number from the successful response
    assert_equal '', response.authorization
    assert response.test?
  end

  def test_unsuccessful_request
    @gateway.expects(:ssl_post).returns(failed_purchase_response)
    
    assert response = @gateway.purchase(@amount, @credit_card, @options)
    assert_failure response
    assert response.test?
  end

  private
  
  # Place raw successful response from gateway here
  def successful_purchase_response
  end
  
  # Place raw failed response from gateway here
  def failed_purcahse_response
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
johnideal-activemerchant-1.4.10 generators/gateway/templates/gateway_test.rb
johnideal-activemerchant-1.4.11 generators/gateway/templates/gateway_test.rb
johnideal-activemerchant-1.4.4 generators/gateway/templates/gateway_test.rb
johnideal-activemerchant-1.4.5 generators/gateway/templates/gateway_test.rb
johnideal-activemerchant-1.4.6 generators/gateway/templates/gateway_test.rb
johnideal-activemerchant-1.4.7 generators/gateway/templates/gateway_test.rb
johnideal-activemerchant-1.4.8 generators/gateway/templates/gateway_test.rb
smulube-activemerchant-1.5.1.4 generators/gateway/templates/gateway_test.rb
smulube-activemerchant-1.5.1.3 generators/gateway/templates/gateway_test.rb
smulube-activemerchant-1.5.1.2 generators/gateway/templates/gateway_test.rb