Sha256: 3c532d9c6bac924a8a1894fdc3ef22e57a74e4ab61c4d8330e85a6d895cb3555

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Equity do
  
  it "should allow creating a equity account" do
    equity = Factory(:equity)
  end
  
  it "should report a balance for the equity account" do
    equity = Factory(:equity)
    equity.balance.should be_kind_of(BigDecimal)
  end
  
  it "should report a balance for the class of accounts" do
    Equity.should respond_to(:balance)
    Equity.balance.should be_kind_of(BigDecimal)
  end
  
  it "should not report a trial balance" do
    lambda{Equity.trial_balance}.should raise_error(NoMethodError)
  end
  
  it "should not be valid without a name" do
    equity = Factory.build(:equity, :name => nil)
    equity.should_not be_valid
  end  
  
  it "should have many credit transactions" do
    equity = Factory(:equity)
    equity.should respond_to(:credit_transactions)
  end

  it "should have many debit transactions" do
    equity = Factory(:equity)
    equity.should respond_to(:debit_transactions)
  end  
  
  it "a contra account should reverse the normal balance" do
    equity = Factory(:equity)
    contra_equity = Factory(:equity, :contra => true)
    transaction = Factory(:transaction, :credit_account => equity, :debit_account => contra_equity, :amount => 1000)
    contra_equity.balance.should > 0
    Equity.balance.should == 0
  end  

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blawzoo-plutus-0.5.3 spec/models/equity_spec.rb
plutus-0.5.2 spec/models/equity_spec.rb
plutus-0.5.1 spec/models/equity_spec.rb
plutus-0.4.2 spec/models/equity_spec.rb