Sha256: 4ad168ae325c2f652cf525e98c6dcc990dce135177f931075963abd23bf66f19

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

module Plutus
  describe Revenue do

    it "should allow creating an revenue account" do
      revenue = FactoryGirl.create(:revenue)
    end

    it "should report a balance for the revenue account" do
      revenue = FactoryGirl.create(:revenue)
      FactoryGirl.create(:credit_amount, :account => revenue)
      revenue.balance.should > 0
      revenue.balance.should be_kind_of(BigDecimal)
    end

    it "should report a balance for the class of accounts" do
      revenue = FactoryGirl.create(:revenue)
      FactoryGirl.create(:credit_amount, :account => revenue)
      Revenue.should respond_to(:balance)
      Revenue.balance.should > 0
      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 = FactoryGirl.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
      contra_revenue = Factory(:revenue, :contra => true)
      # the odd amount below is because factories create an revenue debit_amount
      FactoryGirl.create(:debit_amount, :account => contra_revenue, :amount => 473) 
      contra_revenue.balance.should > 0
      Revenue.balance.should == 0 
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plutus-0.7.2 spec/models/revenue_spec.rb
plutus-0.7.0 spec/models/revenue_spec.rb