Sha256: 5b5f140c5d821c199f27666176e78354ef9c2ef719eb3fb102d7c920b59d02e8

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

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

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

end

Version data entries

4 entries across 4 versions & 2 rubygems

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