ruby on rails - rspec, devise, selenium - login in request spec -
i tried follow these steps https://github.com/plataformatec/devise/wiki/how-to:-test-with-capybara don't pass login page. correct me , show i'm doing wrong? rspec
require 'spec_helper' include warden::test::helpers warden.test_mode! describe "business::contacts" describe "get /business_contacts", js: true before(:each) @account = create :business_account @account.confirmed_at = time.now @account.save login_as(@account, scope: :account, run_callbacks: false) end > "show page restricted access", slow: true > visit business_contacts_path > save_and_open_page > end
factory:
factory :business_account, class: 'account' email { faker::internet.email } username { faker::name.name } first_name { faker::name.name } last_name { faker::name.name } password "foaabar123" password_confirmation { |u| u.password } confirmed_at time.now - 1.day phone_number "2234567890" end
update 1
i've implemented warden.rb
commenting out in factory password_confirmation & changing confirmed_at time.now
error:
1) business::contacts /business_contacts visit restricted webpage failure/error: unable find matching line backtrace nomethoderror: undefined method `env' nil:nilclass
i created warden.rb in spec/support dir:
rspec.configure |config| config.include warden::test::helpers, :type => :request warden.test_mode! config.after(:each) warden.test_reset! end end
then, in request spec:
before(:each) @user = create(:user) login_as(@user, :scope => :user) end
Comments
Post a Comment