require File.expand_path(File.dirname(__FILE__) + '/test_helper') class OFXParserTest < Minitest::Test def test_creating_from_array body = <<-EOS 0INFOSUCCESS20151223151556.657[-5:EST]ENGAB12345201512231515550INFO1USD0712345139876543123547CHECKING20131223151557.601[-5:EST]20151222190000.000[-5:EST]CHECK20151221120000[0:GMT]370.992111111101REMOTE ONLINE DEPOSIT #11000.3520151222190000.000[-5:EST]1200.0920151221190000.000[-5:EST] EOS parser = OFX::OFX102::Parser.new parser.scan_str body # require 'pp' # pp parser.ofx_hashes[0] document = parser.documents[0] signon_message_set = document.message_sets[0] signon_response = signon_message_set.responses[0] banking_statement_message_set = document.message_sets[1] banking_statement_response = banking_statement_message_set.responses[0] assert_equal '9876543123547', banking_statement_response.account.account_identifier assert_equal '071234513', banking_statement_response.account.bank_identifier assert_equal '1200.09', banking_statement_response.available_balance.amount assert_equal '1000.35', banking_statement_response.ledger_balance.amount transactions = banking_statement_response.transactions assert_equal 1, transactions.size transaction = transactions.first assert_equal '370.99', transaction.amount.to_f.to_s assert_equal 'REMOTE ONLINE DEPOSIT #', transaction.payee assert_equal :check, transaction.transaction_type end end