Search⌘ K

Challenge Solution: Log In

Understand how to implement a user login feature in Ruby on Rails and write corresponding feature tests. Learn how to define test steps, edit views for user sessions, and verify login success messages effectively.

Let’s look at the solution to the challenge.

Note: This isn’t the only way to implement the feature and pass the tests.

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"

run Rails.application
Rails.application.load_server
Solution for the log in challenge

Explanation

Let’s break down the solution implemented above.

Define the test steps

We make the following changes to features/step_definitions/login_steps.rb:

  • Lines 1–3: ...