summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-09-27 20:52:04 -0600
committermo k <mo@mokhan.ca>2012-09-27 20:52:04 -0600
commit868cdfb3136d2eceabbd5cd1bb444bd5aa32b09a (patch)
tree9e4c4af15ccd250e3c223525e17bc396874d6572 /spec
parent98db5dfbe7a8ae4d44c90e34e4ebef75f2d75efa (diff)
update the comments controller specs
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/comments_controller_spec.rb46
-rw-r--r--spec/spec_helper.rb1
2 files changed, 18 insertions, 29 deletions
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index 1ea63211..12972217 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -1,32 +1,22 @@
-require_relative '../../app/controllers/comments_controller'
-require 'fakes'
-require 'fakes-rspec'
-
describe CommentsController do
- let(:sut) { CommentsController.new }
-
- describe 'when commenting on a creation' do
- let(:flash_hash) { {} }
- let(:payload){ {:creation_id=>88, :comment => {:body => 'blah'}} }
- let(:command){ fake }
-
- before(:each) do
- sut.stub(:params).and_return(payload)
- sut.stub(:flash).and_return(flash_hash)
- sut.stub(:redirect_to).and_return(nil)
- sut.stub(:command_for).with(CommentOnCreationCommand).and_return(command)
-
- sut.create
- end
-
- it "should save the new comment" do
- command.should have_received(:run, payload)
- end
- it "should display a message indicated that the comment was saved" do
- flash_hash[:notice].should_not be_nil
- end
- it "should redirect to the creation#show page" do
-
+ describe "POST create" do
+ describe "when signed in" do
+ let(:user) { FactoryGirl.create(:user) }
+ let(:creation) { FactoryGirl.create(:creation) }
+ before :each do
+ http_login(user)
+ end
+ describe 'when commenting on a creation' do
+ before(:each) do
+ post :create, {:creation_id => creation.id, :comment => {:body => 'blah'}}
+ end
+ it "should display a message indicated that the comment was saved" do
+ flash[:notice].should_not be_nil
+ end
+ it "should redirect to the creation#show page" do
+ response.should redirect_to(creation)
+ end
+ end
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a2696ee2..3d0a86d6 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,7 +6,6 @@ Spork.prefork do
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
-
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|