Skip to primary content

42

Web notebook about thoughts and discoveries in DevOps, SRE, Software Engineering….

42

Main menu

  • Home
  • About
  • contact
  • Links

Post navigation

← Previous Next →

Use devise to login user for RSpec tests

Posted on 20 October 2011 by kosmas

Problem
You want to test with RSpec for links that are visible only after the user signs into the application.

Solution
Use the following before method in your RSpec test:

before(:each) do
      @user = Factory(:user)
      sign_in @user
end

 

This entry was posted in RSpec, ruby on rails and tagged devise, log in, RSpec, testing by kosmas. Bookmark the permalink.
Proudly powered by WordPress