Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe Item
- describe "#received" do
- it "should return the amount of goods received" do
- receiving_records = mock_model(ReceivingRecord)
- subject.stub(:receiving_records) { receiving_records }
- receiving_records.stub(:sum).with(:quantity) { 3 }
- subject.received.should == 3
- end
- end
- end
- class Item < ActiveRecord::Base
- has_many :receiving_records
- def received
- receiving_records.sum(:amount)
- end
- end
Add Comment
Please, Sign In to add comment