summaryrefslogtreecommitdiff
path: root/spec/controllers/comments_controller_spec.rb
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-06-09 16:56:22 -0600
committermo k <mo@mokhan.ca>2012-06-09 16:56:22 -0600
commit8c973ebf103469831e2be9102e148deb10091cba (patch)
tree28b9863fe1047405ac2f37805f9e1e75dd2bfa33 /spec/controllers/comments_controller_spec.rb
parent26ef5984c0c6dbb1509ce08ba11b7c7b27de45f9 (diff)
start to write happy day tests for comments controller.
Diffstat (limited to 'spec/controllers/comments_controller_spec.rb')
-rw-r--r--spec/controllers/comments_controller_spec.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index 1b4fb834..0d31dad6 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -8,11 +8,30 @@ describe CommentsController do
let(:comment) { fake }
it "should save the new comment" do
- #comment.should have_receieved(:save)
+ comment.should have_received(:save)
+ end
+ it "should displa a message indicated that the comment was saved" do
+ @flash_hash[:notice].should_not be_nil
+ end
+ it "should not display an errors" do
+ @flash_hash[:error].should be_nil
end
before(:each) do
- #Comment.stub(:build_from).and_return(comment)
- #sut.create
+ creation = fake
+ user = fake
+ @flash_hash = {}
+
+ comment.stub(:save).and_return(true)
+ user.stub(:id).and_return(8)
+ sut.stub(:params).and_return({:creation_id=>88, :comment => {:body => 'blah'}})
+ sut.stub(:current_user).and_return(user)
+ sut.stub(:flash).and_return(@flash_hash)
+ sut.stub(:redirect_to).and_return(nil)
+ sut.stub(:creation_path).with(creation).and_return('url')
+ Creation.stub(:find).with(88).and_return(creation)
+ Comment.stub(:build_from).with(creation, 8, 'blah').and_return(comment)
+
+ sut.create
end
end
end