Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created July 19, 2013 14:01
Show Gist options
  • Save kylewelsby/6039321 to your computer and use it in GitHub Desktop.
Save kylewelsby/6039321 to your computer and use it in GitHub Desktop.
RSpec to test a cancan ability of 'create'
class Ability
include CanCan::Ability
def initialize(user)
can :create, Something
end
end
require 'spec_helper'
describe Ability do
it "allows user to create something" do
user = User.new
expect(user).to be_able_to(:create, Something)
end
end
...
require "cancan/matchers"
RSpec.configure do |config|
...
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment