Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.join( File.dirname(__FILE__), '..', "spec_helper" )
- describe Comment do
- it "should be valid when new" do
- comment = Comment.new(:body => "Yesterday the market rose by 5%. I was happy.", :stock_id => '1')
- comment.should be_valid
- end
- it "should not be valid if body is empty" do
- comment = Comment.new(:body => '')
- comment.should_not be_valid
- end
- it "should not be valid if stock_id is empty" do
- comment = Comment.new(:body => 'Yesterday the market rose by 5%. I was happy.', :stock_id => '')
- comment.should_not be_valid
- end
- it "should not be valid if stock_id does not exist" do
- stock = Stock.find(:all) # this is failing because i need fixtures or a stub
- non_existant_stock_id = stock.id.to_i + 1
- comment = Comment.create(:body => 'Yseterday the market rose by 5%. I was happy.', :stock_id => non_existant_stock_id)
- comment.non_existant_stock_id should_not equal(stock.id)
- end
- end
Add Comment
Please, Sign In to add comment