Sha256: ddfebc70b4dfd3d61d3d9da0e61cd78c84981d2b8c4ad59b4dc02312d325f862

Contents?: true

Size: 1.08 KB

Versions: 66

Compression:

Stored size: 1.08 KB

Contents

module Features
  module SessionHelpers
    # Regular login
    def login_as(user)
      user.reload # because the user isn't re-queried via Warden
      super(user, scope: :user, run_callbacks: false)
    end

    # Regular logout
    def logout(user = :user)
      super(user)
    end

    # Poltergeist-friendly sign-up
    # Use this in feature tests
    def sign_up_with(email, password)
      Capybara.exact = true
      visit new_user_registration_path
      fill_in 'Email', with: email
      fill_in 'Password', with: password
      fill_in 'Password confirmation', with: password
      click_button 'Sign up'
    end

    # Poltergeist-friendly sign-in
    # Use this in feature tests
    def sign_in(who = :user)
      user = if who.instance_of?(User)
               who
             else
               FactoryGirl.build(:user).tap(&:save!)
             end
      visit new_user_session_path
      fill_in 'Email', with: user.email
      fill_in 'Password', with: user.password
      click_button 'Log in'
      expect(page).to_not have_text 'Invalid email or password.'
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 spec/support/features/session_helpers.rb
curation_concerns-1.7.7 spec/support/features/session_helpers.rb
curation_concerns-2.0.0 spec/support/features/session_helpers.rb
curation_concerns-2.0.0.rc2 spec/support/features/session_helpers.rb
curation_concerns-1.7.6 spec/support/features/session_helpers.rb
curation_concerns-1.7.5 spec/support/features/session_helpers.rb
curation_concerns-1.7.4 spec/support/features/session_helpers.rb
curation_concerns-1.7.3 spec/support/features/session_helpers.rb
curation_concerns-1.7.2 spec/support/features/session_helpers.rb
curation_concerns-2.0.0.rc1 spec/support/features/session_helpers.rb
curation_concerns-1.7.1 spec/support/features/session_helpers.rb
curation_concerns-1.7.0 spec/support/features/session_helpers.rb
curation_concerns-1.7.0.beta1 spec/support/features/session_helpers.rb
curation_concerns-1.6.3 spec/support/features/session_helpers.rb
curation_concerns-1.6.2 spec/support/features/session_helpers.rb
curation_concerns-1.6.1 spec/support/features/session_helpers.rb
curation_concerns-1.6.0 spec/support/features/session_helpers.rb
curation_concerns-1.5.0 spec/support/features/session_helpers.rb
curation_concerns-1.4.0 spec/support/features/session_helpers.rb
curation_concerns-1.3.3 spec/support/features/session_helpers.rb