Sha256: 78cd49630f8d9330415274f7f77d52c7f6a1bac25e0b692b30d890a89f77f8af

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require "spec_helper"

describe Quicken::Parser do
  let (:file) do
    qif = Quicken::Parser.new('spec/fixtures/default.qif').parse!
  end

  context "account section" do
    it "should return the account" do
      file.account.should == Quicken::Account.new({:number=>"0833_5710633", :type=>"Bank"})
    end

    it "should return nil when the file don't have an account" do
      qif = Quicken::Parser.new('spec/fixtures/ms_money.qif').parse!
      qif.account.should be_nil
    end
  end

  context "transactions section" do
    it "should return the transactions" do
      file.transactions.should_not be_empty
    end

    it "should map each transaction to Transaction objects" do
      file.transactions.first.should be_instance_of(Quicken::Transaction)
      file.transactions.size.should be(4)
    end

    it "should remove carriage return" do
      qif = Quicken::Parser.new('spec/fixtures/ms_money.qif').parse!
      qif.transactions.first.payee.should_not match(/\r/)
    end

    describe "regard to date_format" do
      it "should delegate this to each transaction" do
        qif = Quicken::Parser.new('spec/fixtures/bco_real.qif', [:day, :month, :year]).parse!
        qif.transactions.first.date.should == Date.civil(2010, 04, 19)
      end

      it "should use default value when didn't receive the format" do
        qif = Quicken::Parser.new('spec/fixtures/default.qif').parse!
        qif.transactions.first.date.should == Date.civil(2010, 04, 19)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quicken-0.0.2 spec/quicken/parser_spec.rb
quicken-0.0.1 spec/quicken/parser_spec.rb