Sha256: 6ee3366726e3e7bb5dcd73ffc03bdde78a800bdac1523e1410a22a3aba3a35fa

Contents?: true

Size: 1.16 KB

Versions: 22

Compression:

Stored size: 1.16 KB

Contents

require "<%= @helper_file %>"
require "support/features/clearance_helpers"

RSpec.feature "Visitor signs in" do
  scenario "with valid email and password" do
    create_user "user@example.com", "password"
    sign_in_with "user@example.com", "password"

    expect_user_to_be_signed_in
  end

  scenario "with valid mixed-case email and password " do
    create_user "user.name@example.com", "password"
    sign_in_with "User.Name@example.com", "password"

    expect_user_to_be_signed_in
  end

  scenario "tries with invalid password" do
    create_user "user@example.com", "password"
    sign_in_with "user@example.com", "wrong_password"

    expect_page_to_display_sign_in_error
    expect_user_to_be_signed_out
  end

  scenario "tries with invalid email" do
    sign_in_with "unknown.email@example.com", "password"

    expect_page_to_display_sign_in_error
    expect_user_to_be_signed_out
  end

  private

  def create_user(email, password)
    FactoryBot.create(:user, email: email, password: password)
  end

  def expect_page_to_display_sign_in_error
    expect(page.body).to include(
      I18n.t("flashes.failure_after_create", sign_up_path: sign_up_path),
    )
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
clearance-1.16.2 lib/generators/clearance/specs/templates/features/clearance/visitor_signs_in_spec.rb.tt
clearance-1.16.1 lib/generators/clearance/specs/templates/features/clearance/visitor_signs_in_spec.rb.tt