0
votes

I've the following problem with a newly set up rails project. Somehow I can't seem to get the Devise helpers (such as sign_in) to be required properly.

In my spec/support dir. I have a file called devise which should, according to Device's readme file, include the helper methods so you can use them in RSpec:

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
end

My spec_helper.rb has, of course:

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

I've been fighting over this thing for over an hour and it's driving me insane. Help is much appreciated!

Using:

  1. Rspec 2.2.0
  2. Devise 1.1.5
  3. Rails 3.0.3
1
>> I have a file called devise << You mean devise.rb, right?zetetic

1 Answers

0
votes

While it seems it should be identical, i would propose to try to include the testhelpers explicitly inside your rspec test. Like this:

require 'spec_helper'

describe DoStuffController do
  include Devise::TestHelpers

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

  ... do your stuff ...

end

If that still fails, which i assume it will, i am hoping you will at least get a better error.