Sha256: 788e0b925146c9091d892985429cfcb44ed714ba8584041df711ef8c61dbcfe0

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

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

  it "should have many debit transactions" do
    liability = Factory(:liability)
    liability.should respond_to(:debit_transactions)
  end  

  it "a contra account should reverse the normal balance" do
    liability = Factory(:liability)
    contra_liability = Factory(:liability, :contra => true)
    transaction = Factory(:transaction, :credit_account => liability, :debit_account => contra_liability, :amount => 1000)
    contra_liability.balance.should > 0
    Liability.balance.should == 0
  end  

end

Version data entries

4 entries across 4 versions & 2 rubygems

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