Devise test helper not loading, or being required properly in RSpec
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, :ty开发者_JAVA技巧pe => :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:
- Rspec 2.2.0
- Devise 1.1.5
- Rails 3.0.3
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.
精彩评论