Guest User

Untitled

a guest
Feb 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. require File.join( File.dirname(__FILE__), '..', "spec_helper" )
  2.  
  3. describe Comment do
  4.  
  5. it "should be valid when new" do
  6. comment = Comment.new(:body => "Yesterday the market rose by 5%. I was happy.", :stock_id => '1')
  7. comment.should be_valid
  8. end
  9.  
  10. it "should not be valid if body is empty" do
  11. comment = Comment.new(:body => '')
  12. comment.should_not be_valid
  13. end
  14.  
  15. it "should not be valid if stock_id is empty" do
  16. comment = Comment.new(:body => 'Yesterday the market rose by 5%. I was happy.', :stock_id => '')
  17. comment.should_not be_valid
  18. end
  19.  
  20. it "should not be valid if stock_id does not exist" do
  21. stock = Stock.find(:all) # this is failing because i need fixtures or a stub
  22. non_existant_stock_id = stock.id.to_i + 1
  23. comment = Comment.create(:body => 'Yseterday the market rose by 5%. I was happy.', :stock_id => non_existant_stock_id)
  24. comment.non_existant_stock_id should_not equal(stock.id)
  25. end
  26. end
Add Comment
Please, Sign In to add comment