require 'test_helper'
class DashboardControllerTest < ActionController::TestCase
include Devise::TestHelpers
include Warden::Test::Helpers
Warden.test_mode!
test "should get index" do
get :index
assert_response :success
end
end
I included Warden::Test::Helpers as directed to by other stack posts but I'm still getting the uncaught throw :warden and it's driving me crazy. Save me? :[
Ah my crisis was averted by merely creating a user within the test instead of using fixtures
describe "user does something" do
it "allows users to do something" do
User.create!(email: "[email protected]", password: "abcdef", first_name: 'Jim', last_name: 'Bo', username: 'somename')
I put the code above before raising any expectations and everything was fine. For some reason when I was testing a user with the automatically generated tests and fixtures the uncaught throw :warden was raised
class StudentsControllerTest < ActionController::TestCase
setup do
@student = students(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:students)
end
end
The above being an example of a basic test that would fail and the below being an example of a fixture I used something like below
one:
first_name: User
last_name: Example
email: [email protected]
password: abcdef
encrypted_password: <%= User.new.send(:password_digest, 'lalala') %>