Sha256: 6957111214d922d7cde65e933aa812e26c3479ef0b1fd6f891e6dd52f76cd30f

Contents?: true

Size: 901 Bytes

Versions: 6

Compression:

Stored size: 901 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 TwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME, value
  end

  def get_tfa_cookie
    get_cookie TwoFactorAuthentication::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

6 entries across 6 versions & 1 rubygems

Version Path
two_factor_authentication-2.2.0 spec/support/features_spec_helper.rb
two_factor_authentication-2.1.1 spec/support/features_spec_helper.rb
two_factor_authentication-2.1.0 spec/support/features_spec_helper.rb
two_factor_authentication-2.0.1 spec/support/features_spec_helper.rb
two_factor_authentication-2.0.0 spec/support/features_spec_helper.rb
two_factor_authentication-1.1.5 spec/support/features_spec_helper.rb