Sha256: 22ae71b48539e9d472f09dceea8d8a3dadb99319cdba9dd3084849003e886886

Contents?: true

Size: 889 Bytes

Versions: 10

Compression:

Stored size: 889 Bytes

Contents

require 'warden'

module FeaturesSpecHelper
  def warden
    request.env['warden']
  end

  def complete_sign_in_form_for(user)
    fill_in "Email", with: user.email
    fill_in "Password", with: 'password'
    find('.actions input').click # 'Sign in' or 'Log in'
  end

  def set_cookie key, value
    page.driver.browser.set_cookie [key, value].join('=')
  end

  def get_cookie key
    Capybara.current_session.driver.request.cookies[key]
  end

  def set_tfa_cookie value
    set_cookie DeviseMultiFactor::REMEMBER_TFA_COOKIE_NAME, value
  end

  def get_tfa_cookie
    get_cookie DeviseMultiFactor::REMEMBER_TFA_COOKIE_NAME
  end
end

RSpec.configure do |config|
  config.include Warden::Test::Helpers, type: :feature
  config.include FeaturesSpecHelper, type: :feature

  config.before(:each) do
    Warden.test_mode!
  end

  config.after(:each) do
    Warden.test_reset!
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
devise-multi-factor-3.2.5 spec/support/features_spec_helper.rb
devise-multi-factor-3.2.4 spec/support/features_spec_helper.rb
devise-multi-factor-3.2.3 spec/support/features_spec_helper.rb
devise-multi-factor-3.2.2 spec/support/features_spec_helper.rb
devise-multi-factor-3.2.1 spec/support/features_spec_helper.rb
devise-multi-factor-3.2.0 spec/support/features_spec_helper.rb
devise-multi-factor-3.1.8 spec/support/features_spec_helper.rb
devise-multi-factor-3.1.7 spec/support/features_spec_helper.rb
devise-multi-factor-3.1.6 spec/support/features_spec_helper.rb
devise-multi-factor-3.1.5 spec/support/features_spec_helper.rb