Sha256: 391d81226a8a4d0b6995a12d82a0c49dc41639f5138afe4633f99564dc18f6cf

Contents?: true

Size: 1.56 KB

Versions: 14

Compression:

Stored size: 1.56 KB

Contents

require 'test_helper'

class RemoteStoreTest < Test::Unit::TestCase

  def setup
    @environment = Spreedly::Environment.new(remote_test_environment_key, remote_test_access_secret)
  end

  def test_invalid_login
    assert_invalid_login do |environment|
      environment.store_on_gateway('gtoken', 'ptoken')
    end
  end

  def test_payment_method_not_found
    assert_raise_with_message(Spreedly::TransactionCreationError, "There is no payment method corresponding to the specified payment method token.") do
      @environment.store_on_gateway('gateway_token', 'unknown_payment_method')
    end
  end

  def test_gateway_not_found
    card_token = create_card_on(@environment).token
    assert_raise_with_message(Spreedly::NotFoundError, "Unable to find the specified gateway.") do
      @environment.store_on_gateway('unknown_gateway', card_token)
    end
  end

  def test_successful_store
    gateway_token = @environment.add_gateway(:test).token
    card_token = create_card_on(@environment).token

    transaction = @environment.store_on_gateway(gateway_token, card_token)
    assert transaction.succeeded?
    assert_equal card_token, transaction.basis_payment_method.token
    assert transaction.payment_method.third_party_token
  end

  def test_failed_store
    gateway_token = @environment.add_gateway(:test).token
    card_token = create_card_on(@environment, number: "4217651111111119").token

    transaction = @environment.store_on_gateway(gateway_token, card_token)
    assert !transaction.succeeded?
    assert_equal "Unable to store card", transaction.message
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
spreedly-2.0.28 test/remote/remote_store_test.rb
spreedly-2.0.27 test/remote/remote_store_test.rb
spreedly-2.0.26 test/remote/remote_store_test.rb
spreedly-2.0.25 test/remote/remote_store_test.rb
spreedly-2.0.24 test/remote/remote_store_test.rb
spreedly-2.0.23 test/remote/remote_store_test.rb
spreedly-2.0.22 test/remote/remote_store_test.rb
spreedly-2.0.21 test/remote/remote_store_test.rb
spreedly-2.0.20 test/remote/remote_store_test.rb
spreedly-2.0.19 test/remote/remote_store_test.rb
spreedly-2.0.18 test/remote/remote_store_test.rb
spreedly-2.0.17 test/remote/remote_store_test.rb
spreedly-2.0.16 test/remote/remote_store_test.rb
spreedly-2.0.15 test/remote/remote_store_test.rb