How to create the first (Admin) user (CanCan and Devise)?

You can do it from the rails console. From the command line goto the directory of your rails application and type rails console. Then enter the following code to create a user: user=User.create!(:email=>'[email protected]’,:username=>’test’,:password=>’password’) This will create a user object (assuming your devise resource is called User). Now you can use the user object that you … Read more

How to do integration testing with RSpec and Devise/CanCan?

@pschuegr’s own answer got me across the line. For completeness, this is what I did that gets me easily set up for both request specs and controller specs (using FactoryGirl for creating the user instance): in /spec/support/sign_in_support.rb: #module for helping controller specs module ValidUserHelper def signed_in_as_a_valid_user @user ||= FactoryGirl.create :user sign_in @user # method from … Read more