Add a logic error and detect it with a test

❮ Back Next ❯

Task

Steps

class LimericksController < ApplicationController

  before_action :authenticate_user!, except: [:index]
  before_action :require_permission, except: [:index, :new, :create]

  def index
    @limericks = Limerick.take(1)
    render :index
  end

  ...
rails test -v
Running 1 tests in a single process (parallelization threshold is 50)
Run options: -v --seed 31239

# Running:

LimericksControllerTest#test_should_get_index = 2.24 s = F


Failure:
LimericksControllerTest#test_should_get_index [test/controllers/limericks_controller_test.rb:8]:
Expected exactly 2 elements matching "div.card", found 1..
Expected: 2
  Actual: 1


rails test test/controllers/limericks_controller_test.rb:4


Finished in 2.243783s, 0.4457 runs/s, 0.8914 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips

❮ Back Next ❯