Authentication 在水豚特征测试中,我是否可以使用Desive helper‘sign_in’的等价物?
我正在尝试为一个资源编写一个功能测试,该资源只对登录用户可用,是否有一个等效的helpr方法来设计我可以使用的“登录”,或者我必须通过登录过程手动使用水豚Authentication 在水豚特征测试中,我是否可以使用Desive helper‘sign_in’的等价物?,authentication,capybara,integration-testing,Authentication,Capybara,Integration Testing,我正在尝试为一个资源编写一个功能测试,该资源只对登录用户可用,是否有一个等效的helpr方法来设计我可以使用的“登录”,或者我必须通过登录过程手动使用水豚 require 'rails_helper' require_relative '../support/new_quote_form' feature 'creating quote request' do let(:user) { FactoryGirl.create(:user) } let(:new_quote_for
require 'rails_helper'
require_relative '../support/new_quote_form'
feature 'creating quote request' do
let(:user) { FactoryGirl.create(:user) }
let(:new_quote_form) { NewQuoteForm.new }
before do
sign_in(user) #Would be nice and easy!
end
scenario 'completing quote data' do
new_quote_form.visit_page.fill_in_with().submit
expect(page).to have_content('Quote request created')
end
scenario 'cannot reqest quote with invalid data' do
new_quote_form.visit_page.submit
expect(page).to have_content("Must be selected")
end
end
典狱长测试助手可以与Desive和Capybara一起使用,在这里进行快捷登录。下面是Devises wiki上的文章,讨论这个问题- 在spec/rails\u helper.rb中包含Include Warden::Test::Helpers,然后您可以在您的设备用户上使用login\u as,例如login\u asuser,:scope=>:user