Sha256: 6bada49651df06b433881f9f7f0eaed4a89006659640f5c3a101ce94032c0686

Contents?: true

Size: 975 Bytes

Versions: 9

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

module ESA
  describe Account do
    let(:account) { FactoryGirl.build(:account) }
    subject { account }
    
    # must construct a child type instead
    it { should_not be_valid }

    # must respond to normal_balance, but always answer "none"
    it { should respond_to(:normal_balance) }
    its(:normal_balance) { should be_kind_of(Enumerize::Value) }
    its(:normal_balance) { should eq("none") }

    # must respond to balance, but always answer nil
    it { should respond_to(:balance) }
    its(:balance) { should be_nil }

    describe "when using a child type" do
      let(:account) { FactoryGirl.create(:account, type: "Finance::Asset") }
      it { should be_valid }
      
      it "should be unique per name" do
        conflict = FactoryGirl.build(:account, name: account.name, type: account.type)
        conflict.should_not be_valid
        conflict.errors[:name].should == ["has already been taken"]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
event_sourced_accounting-0.2.6 spec/models/account_spec.rb
event_sourced_accounting-0.2.4 spec/models/account_spec.rb
event_sourced_accounting-0.2.3 spec/models/account_spec.rb
event_sourced_accounting-0.2.2 spec/models/account_spec.rb
event_sourced_accounting-0.1.6 spec/models/account_spec.rb
event_sourced_accounting-0.1.4 spec/models/account_spec.rb
event_sourced_accounting-0.1.3 spec/models/account_spec.rb
event_sourced_accounting-0.1.1 spec/models/account_spec.rb
event_sourced_accounting-0.1.0 spec/models/account_spec.rb