Skip to content

Instantly share code, notes, and snippets.

@patrick99e99
Created May 23, 2012 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrick99e99/2778523 to your computer and use it in GitHub Desktop.
Save patrick99e99/2778523 to your computer and use it in GitHub Desktop.
describe OffersController do
def do_create
post :create, { :post_id => bb_request.id, :offer => new_offer.attributes }
end
shared_examples "an access controlled action" do |action_proc|
it "denies access if the post is not verified" do
expect(&action_proc).to raise_error(CanCan::AccessDenied)
end
end
describe "#create" do
it_behaves_like "an access controlled action", proc { do_create }
end
end
...
Failure/Error: expect(&action_proc).to raise_error(CanCan::AccessDenied)
expected CanCan::AccessDenied, got #<NameError: undefined local variable or method `do_create' for RSpec::Core::ExampleGroup::Nested_1::Nested_2:Class>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment