Guest User

Untitled

a guest
Sep 23rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. describe Item
  2. describe "#received" do
  3. it "should return the amount of goods received" do
  4. receiving_records = mock_model(ReceivingRecord)
  5. subject.stub(:receiving_records) { receiving_records }
  6. receiving_records.stub(:sum).with(:quantity) { 3 }
  7. subject.received.should == 3
  8. end
  9. end
  10. end
  11.  
  12. class Item < ActiveRecord::Base
  13. has_many :receiving_records
  14.  
  15. def received
  16. receiving_records.sum(:amount)
  17. end
  18. end
Add Comment
Please, Sign In to add comment