Skip to content

Instantly share code, notes, and snippets.

@cupakromer
Created October 16, 2012 16:08
Show Gist options
  • Save cupakromer/3900265 to your computer and use it in GitHub Desktop.
Save cupakromer/3900265 to your computer and use it in GitHub Desktop.
RSpec good idea?
describe CommentsController do
describe '#create' do
context 'with valid form' do
let(:expect_commenting) { expect{ post :create, comment: { user_id: 1, body: "This is a comment" } } }
subject {
post :create, comment: { user_id: 1, body: "This is a comment" }
@controller
}
it { expect_commenting.to change{Comment.count}.by 1 }
it { should redirect_to comments_path }
it { should set_the_flash[:notice].to 'Comment Created!' }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment