Skip to content

Instantly share code, notes, and snippets.

@jadehopepunk
Created April 12, 2012 00:35
Show Gist options
  • Save jadehopepunk/2363764 to your computer and use it in GitHub Desktop.
Save jadehopepunk/2363764 to your computer and use it in GitHub Desktop.
further refactored test
require 'spec_helper'
describe CommentsController do
let (:motion) { mock_model(Motion) }
let (:comment) { mock_model(Comment, :default_motion => motion) }
context "deleting comment" do
stub_app_controller_resource(:comment)
it "requires an authorised resource" do
app_controller.should_receive(:authorize!).and_return(true)
delete :destroy, id: 23
end
it "adds a message to the flash" do
delete :destroy, id: 23
flash[:notice].should match(/Comment deleted/)
end
it "redirects to the comment's motion" do
delete :destroy, id: 23
response.should redirect_to(motion_path(motion))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment