Sha256: be2b6e269d0f385ccb632d5137430ee74985a547d86d889499d14c75a6c23e46

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require File.dirname(__FILE__) + '/../../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

4 entries across 4 versions & 3 rubygems

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