app/controllers/limericks_controller.rb
file, but this time to add a logic bug instead of a syntax error.
index
method, replace the call to Limerick.all.reverse_order
with a call to Limerick.take(2)
(which returns a collection of Limerick
objects containing only 2 limericks).class LimericksController < ApplicationController
before_action :authenticate_user!, except: [:index]
before_action :require_permission, except: [:index, :new, :create]
def index
@limericks = Limerick.take(2)
render :index
end
...
Note that this code now clearly contains a logic error—no matter how many limericks are in the database, the app will only ever display 2 of them; however, because we happen to have 2 Limerick
test fixtures, the assertion assert_select 'div.card', limericks_size
will not report a failure.
Run all tests to check for errors.
rails test -v
Running 1 tests in a single process (parallelization threshold is 50)
Run options: -v --seed 389
# Running:
LimericksControllerTest#test_should_get_index = 2.11 s = .
Finished in 2.112802s, 0.4733 runs/s, 0.9466 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips