Sha256: 28113c583870fc7107771c04419aeb95d57d07e676f0d0a9ff089dbf68b8411d

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 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 do |u|
                 u.save!
               end
             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

7 entries across 7 versions & 2 rubygems

Version Path
curation_concerns-0.1.0 spec/support/features/session_helpers.rb
worthwhile-0.1.2 spec/support/features/session_helpers.rb
worthwhile-0.1.1 spec/support/features/session_helpers.rb
worthwhile-0.1.0 spec/support/features/session_helpers.rb
worthwhile-0.0.3 spec/support/features/session_helpers.rb
worthwhile-0.0.2 spec/support/features/session_helpers.rb
worthwhile-0.0.1 spec/support/features/session_helpers.rb