Commit 8c973ebf

mo k <mo@mokhan.ca>
2012-06-09 22:56:22
start to write happy day tests for comments controller.
1 parent 26ef598
Changed files (1)
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