Sha256: 095f0b29f5ff5ad779ca98655cd2ae54107ef4517521703457cb0652e344599a

Contents?: true

Size: 1.52 KB

Versions: 34

Compression:

Stored size: 1.52 KB

Contents

require 'test_helper'

class NochexHelperTest < Test::Unit::TestCase
  include ActiveMerchant::Billing::Integrations
  
  def setup
    @helper = Nochex::Helper.new('order-500','cody@example.com', :amount => 500, :currency => 'GBP')
  end
 
  def test_basic_helper_fields
    assert_field 'email', 'cody@example.com'

    # Nochex requires 2 decimal places on the amount
    assert_field 'amount', '5.00'
    assert_field 'ordernumber', 'order-500'
  end
  
  def test_customer_fields
    @helper.customer :first_name => 'Cody', :last_name => 'Fauser', :email => 'cody@example.com'
    assert_field 'firstname', 'Cody'
    assert_field 'lastname', 'Fauser'
    assert_field 'email_address_sender', 'cody@example.com'
  end

  def test_address_mapping
    @helper.billing_address :address1 => '1 My Street',
                            :city => 'Leeds',
                            :state => 'Yorkshire',
                            :zip => 'LS2 7EE'
   
    assert_field 'firstline', '1 My Street'
    assert_field 'town', 'Leeds'
    assert_field 'county', 'Yorkshire'
    assert_field 'postcode', 'LS2 7EE'
  end
  
  def test_unknown_address_mapping
    @helper.billing_address :country => 'CA'
    assert_equal 3, @helper.fields.size
  end

  def test_unknown_mapping
    assert_nothing_raised do
      @helper.company_address :address => '500 Dwemthy Fox Road'
    end
  end
  
  def test_setting_invalid_address_field
    fields = @helper.fields.dup
    @helper.billing_address :street => 'My Street'
    assert_equal fields, @helper.fields
  end
end

Version data entries

34 entries across 34 versions & 11 rubygems

Version Path
smulube-activemerchant-1.5.1.3 test/unit/integrations/helpers/nochex_helper_test.rb
smulube-activemerchant-1.5.1.2 test/unit/integrations/helpers/nochex_helper_test.rb
ghazel-activemerchant-1.4.2 test/unit/integrations/helpers/nochex_helper_test.rb
activemerchant-est-1.4.2.6 test/unit/integrations/helpers/nochex_helper_test.rb
activemerchant-1.5.0 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2.6 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2.5 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2.4 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2.3 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2.2 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2.1 test/unit/integrations/helpers/nochex_helper_test.rb
activemerchant-est-1.4.2.5 test/unit/integrations/helpers/nochex_helper_test.rb
patmaddox-activemerchant-1.4.2 test/unit/integrations/helpers/nochex_helper_test.rb
abtain_billing-1.0 test/unit/integrations/helpers/nochex_helper_test.rb