Sha256: eeabf51d8a79ebde3a1c4efe7cf3af8336907b78ee1b341e68bb7d92d4b82673

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

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

class TransporterTest < Test::Unit::TestCase

  def test_invalid_transport_type
    txn = ::EWS::Transaction::Request.new({
      :transaction_type => :purchase,
      :amount => "10.13",
      :cardholder_name => "Simon Brown",
      :cc_number => "4111111111111111",
      :cc_expiry => "1012",
      :reference_no => "987987",
    }.merge(EMERGIS_BASIC_AUTH))

    tr = ::EWS::Transporter.new(LOCATION)

    # should raise an exception when transport_type is not one of :json, :rest or :soap
    assert_raises(ArgumentError) {
      tr.submit(txn, :banana)
    }
  end
  
  def test_no_errors_thrown
    txn = ::EWS::Transaction::Request.new({
      :transaction_type => :purchase,
      :amount => "10.13",
      :cardholder_name => "Simon Brown",
      :cc_number => "4111111111111111",
      :cc_expiry => "1012",
      :reference_no => "987987",
    }.merge(EMERGIS_BASIC_AUTH))    

    assert_nothing_raised {
      tr = ::EWS::Transporter.new(LOCATION)
      tr.submit(txn)
    }
  end

  def test_returns_response_object_on_server_failure
    req = ::EWS::Transaction::Request.new({
      :transaction_type => :transaction_details
    }.merge(EMERGIS_BASIC_AUTH))  
    
    req.transaction_tag = 9000  # non-existent txn
    
    tr = ::EWS::Transporter.new(LOCATION)
    resp = tr.submit(req, :json)
    
    assert_not_nil resp
    assert_equal 404, resp.error_number
    assert_equal "Not Found", resp.error_description
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exact4r-0.9.3 ./test/general/transporter_test.rb
exact4r-0.9.2 ./test/general/transporter_test.rb