samedi 12 septembre 2015

FactoryGirl error :warden with RSpec in Rails 4

When I test one of my spec's, I continue to receive this issue:

Failure/Error: visit "/"
UncaughtThrowError:
uncaught throw :warden

Below are the various sections of code:

#_spec.rb
require "rails_helper"

RSpec.feature "Users can create a new discussion" do
  before do
    login_as(FactoryGirl.create(:user))

    visit "/"
    click_link "Discussions"
    click_link "Start a discussion"
  end

  scenario "with valid attributes" do
    click_button "Post"
  end
end

#_factory.rb
FactoryGirl.define do
  factory :user do
    sequence(:email) { |n| "test#{n}@example.com" }
    password "password"
    sequence(:user_name) { |n| "User#{n}" }
    first_name "Test"
    last_name "User"
    country "United States"
    state "Nevada"
    city "Las Vegas"
  end
end

#rails_helper
config.include Warden::Test::Helpers, type: :feature
config.after(type: :feature) { Warden.test_reset! }

Obviously the test is flagging the visit line within the _spec file but I am unsure as to why. If there is any other code I could add to help, please let me know, thank you!

Aucun commentaire:

Enregistrer un commentaire