Sha256: 64e8a29b4fccc0a34edce8f0d7231e644fb6a9d1508eb0ebbc3bd2f1ba42ef02

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

module Features
  module ClearanceHelpers
    def reset_password_for(email)
      visit new_password_path
      fill_in "password_email", with: email
      click_button I18n.t("helpers.submit.password.submit")
    end

    def sign_in
      password = "password"
      user = FactoryBot.create(:user, password: password)
      sign_in_with user.email, password
    end

    def sign_in_with(email, password)
      visit sign_in_path
      fill_in "session_email", with: email
      fill_in "session_password", with: password
      click_button I18n.t("helpers.submit.session.submit")
    end

    def sign_out
      click_button I18n.t("layouts.application.sign_out")
    end

    def sign_up_with(email, password)
      visit sign_up_path
      fill_in "user_email", with: email
      fill_in "user_password", with: password
      click_button I18n.t("helpers.submit.user.create")
    end

    def expect_user_to_be_signed_in
      visit root_path
      expect(page).to have_button I18n.t("layouts.application.sign_out")
    end

    def expect_user_to_be_signed_out
      visit root_path
      expect(page).to have_content I18n.t("layouts.application.sign_in")
    end

    def user_with_reset_password
      user = FactoryBot.create(:user)
      reset_password_for user.email
      user.reload
    end
  end
end

RSpec.configure do |config|
  config.include Features::ClearanceHelpers, type: :feature
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
clearance-2.9.3 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.9.2 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.9.1 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.9.0 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.8.0 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.7.2 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.7.0 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.6.2 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.6.1 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
clearance-2.6.0 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb