Wednesday, 25 August 2010

Testing with devise

Today I ran across a problem getting tests to pass with Devise. There were in fact two issues. First, in rails 3 the Gemfile does not stipulate the order in which gems are loaded and this can mess things up a bit. Especially with mocha, which I use for mocking and stubbing.

This post describes the issue.

To solve the problem I put

require 'mocha'
Bundler.require(:test)
include Devise::TestHelpers



at the end of test/helper.rb

But the sets still didn't pass ....

The other problem to which the solution was more obvious when I actually thought about it was because I am using confirmable. So the setup needed to be:

def setup
@user = users(:one)
sign_in @user
@user.confirm!
end

No comments: