RailsApps/rails3-devise-rspec-cucumber — Issue #21: Rspec controller tests fail when added authenticate_user to the controller
Author: slarti42uk
Created: 2012-02-02 12:57:58+00:00
State: open

Thanks for the great application templates and tutorials!

I'm not sure that this is an issue with the template app or a wider issue but here goes. I'm using the template as a base for a prototype app that requires login for all parts of it. I've used the rails scaffolds to quickly add some functionality and this has created the rspec controller tests. These all run fine until I add `before_filter :authenticate_user! ` to the controller and then all rspec controller tests fail.

I've followed the steps from the Devise wiki and other stackoverflow posts about adding in the Devise test helpers into spec_helper.rb

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

and a before block into the controller test

```ruby
before (:each) do
@user = User.create!({
:name => 'Test User',
:emai => 'user@test.com',
:password => 'please',
:password_confirmation => 'please'
})
sign_in @user
end
```

I understand that cucumber should be used for the integration testing but I just want to find out if this is something that CAN work. I figure that the generated tests are there for free so every extra bit of test coverage is good, yes?

Thanks in advance.