I have a problem with my controller checks for my Course Controller. It seems that the application will not sign my user correctly. All generated controller tests for this controller only fail.
I create my user in users.rb using Factory -girl as below ...
FactoryGirl.define do factory :user do sequence :email do |n| "test#{n}@email.com" end password "password" password_confirmation "password" end end
Then in my courses_controller_spec.rb I mimic the login as described below.
require 'spec_helper' describe CoursesController do include Devise::TestHelpers before(:each) do
And I get the conclusion ...
Failure/Error: response.should redirect_to(courses_url) Expected response to be a redirect to <http:
Note that I also used the following in my spec_helper.rb
config.include Devise::TestHelpers, :type => :controller
And I tried this as https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29
In my query specifications, I can create a user and login using the following, which works fine, but I would also like to get all the controller tests.
fill_in "Email", :with => user.email fill_in "Password", :with => user.password click_button "Sign in"
Any help here would be greatly appreciated.
source share