If I have a Devise model User, of which only those users with role :admin are allowed to view a certain url, how can I write an RSpec integration test to check that the stat
You can create a macro (/spec/support/controller_macros.rb) and write something like :
module ControllerMacros
def login_user
before(:each) do
@request.env["devise.mapping"] = :user
@user = Factory(:user)
sign_in @user
end
end
end
You can also include any CanCan attributes you want. Then, in your spec :
describe YourController do
login_user
it "should ..." do
end