# frozen_string_literal: true

require 'rails_helper'

feature 'Sign in' do
  given(:user) { create(:user, password: 'valid_pw') }
  before { user.save!; visit root_path }

  scenario 'with valid password' do
    expect(page).to have_field('password')

    fill_in 'password', with: user.password
    find('button[type="submit"]').click
    expect(page).to have_content 'Signed in successfully.'
  end

  scenario 'with invalid password' do
    fill_in 'password', with: 'wrong_pw'
    find('button[type="submit"]').click
    expect(page).to have_content 'Invalid password.'
  end

  scenario 'with an invalid authentication token' do
    skip 'How to test this?'
    # Maybe like this: https://stackoverflow.com/a/34007085/6875981
  end
end

# frozen_string_literal: true

require 'rails_helper'

feature 'Sign in' do
  given(:user) { create(:user, password: 'valid_pw') }
  before { user.save!; visit root_path }

  scenario 'with valid password' do
    expect(page).to have_field('password')

    fill_in 'password', with: user.password
    find('button[type="submit"]').click
    expect(page).to have_content 'Signed in successfully.'
  end

  scenario 'with invalid password' do
    fill_in 'password', with: 'wrong_pw'
    find('button[type="submit"]').click
    expect(page).to have_content 'Invalid password.'
  end
end

Remove pending invalid authentication token spec
Remove pending invalid authentication token spec

Unable to implement (with reasonable effort).

First attempt:

```ruby
 # frozen_string_literal: true

require 'rails_helper'

describe BenchmarkDefinitionsController do
  let(:benchmark_definition) { attributes_for(:benchmark_definition) }

  # StackOverflow: https://stackoverflow.com/questions/28947241/how-to-post-with-missing-authenticity-token-in-rspec-rails-request-test
  context 'invalid authenticity token' do
    before do
      ActionController::Base.allow_forgery_protection = true
    end
    it 'should throw an InvalidAuthenticityToken exception' do
      # Handle unverified request is triggered first!
      expect { post benchmark_definitions_path, params: benchmark_definition }.to raise_error(ActionController::InvalidAuthenticityToken)
    end
    after do
      ActionController::Base.allow_forgery_protection = false
    end
  end
end
```
