Skip to content

Instantly share code, notes, and snippets.

@ryanjosephking
Created May 24, 2012 00:26
Show Gist options
  • Select an option

  • Save ryanjosephking/2778599 to your computer and use it in GitHub Desktop.

Select an option

Save ryanjosephking/2778599 to your computer and use it in GitHub Desktop.
require 'spec_helper'
module CanCan
class AccessDenied < Exception; end
end
describe "StaticPages" do
before :each do
def @this.do_create
# …
fail CanCan::AccessDenied.new
end
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 { @this.do_create }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment