Sha256: 64234861909e306e2e4c3fd68924e19718dedf53f0ad45d0fcbf3713185884f5

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Auth log in", type: :feature do
  def fill_in_and_submit_login_form_with(email = "", password = "")
    fill_in_login_form_with(email, password)
    click_button "Log in"
  end

  describe "with login attempts" do
    let(:email) { "me@example.com" }

    before { create(:user, email: email) }

    it "returns message after 1 failed login attempt" do
      visit "/account/login"

      fill_in_and_submit_login_form_with(email, "wrong-password")

      expect(page).to have_content("Invalid Email or password")
    end

    it "returns message after 2 failed login attempts" do
      visit "/account/login"

      2.times { fill_in_and_submit_login_form_with(email, "wrong-password") }

      expect(page).to have_content("Invalid Email or password")
    end

    it "returns warning message after 3 failed login attempts" do
      visit "/account/login"

      3.times { fill_in_and_submit_login_form_with(email, "wrong-password") }

      expect(page).to have_content(
        "You have one more attempt before your account is locked"
      )
    end

    it "locks account after 5 failed login attempts" do
      visit "/account/login"

      4.times { fill_in_and_submit_login_form_with(email, "wrong-password") }

      expect(page).to have_content("Your account is locked.")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/features/auth/log_in/attempts_spec.rb