Sha256: b982d71ea4ce1300460adca15e648723f5fbb1547fb9ff613c475079f9abf003

Contents?: true

Size: 914 Bytes

Versions: 34

Compression:

Stored size: 914 Bytes

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')

class CurrencyTest < Test::Unit::TestCase
  
  # Tests that a currency can be converted into XML that Xero can understand, and then converted back to a currency
  def test_build_and_parse_xml
    currency = create_test_currency
    
    # Generate the XML message
    currency_as_xml = currency.to_xml

    # Parse the XML message and retrieve the account element
    currency_element = REXML::XPath.first(REXML::Document.new(currency_as_xml), "/Currency")

    # Build a new account from the XML
    result_currency = XeroGateway::Currency.from_xml(currency_element)
    
    # Check the account details
    assert_equal currency, result_currency
  end
  
  
  private
  
  def create_test_currency
    XeroGateway::Currency.new.tap do |currency|
      currency.code        = "NZD"
      currency.description = "New Zealand Dollar"
    end
  end
end

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
xero_gateway-2.7.0 test/unit/currency_test.rb
xero_gateway-2.6.0 test/unit/currency_test.rb
xero_gateway-2.5.0 test/unit/currency_test.rb
xero_gateway-2.4.0 test/unit/currency_test.rb
xero_gateway-2.3.0 test/unit/currency_test.rb
xero_gateway-float-2.1.7 test/unit/currency_test.rb
xero_gateway-float-2.1.6 test/unit/currency_test.rb
xero_gateway-float-2.1.4 test/unit/currency_test.rb
xero_gateway-float-2.1.3 test/unit/currency_test.rb
xero_gateway-float-2.1.1 test/unit/currency_test.rb
xero_gateway-float-2.0.18 test/unit/currency_test.rb
xero_gateway-float-2.0.17 test/unit/currency_test.rb
xero_gateway-float-2.0.16 test/unit/currency_test.rb
xero_gateway-float-2.0.15 test/unit/currency_test.rb
xero_gateway-2.1.0 test/unit/currency_test.rb
xero_gateway-n8vision-2.0.20 test/unit/currency_test.rb
xero_gateway-2.0.19 test/unit/currency_test.rb
xero_gateway-2.0.18 test/unit/currency_test.rb
xero_gateway-2.0.17 test/unit/currency_test.rb
xero_gateway-2.0.16 test/unit/currency_test.rb