ruby 2.6.3 rails 6.0.3 AWS cloud9
michael:
  name: Michael Example
  email: [email protected]
  password_digest: <%= User.digest('password') %>
archer:
  name: Sterling Archer
  email: [email protected]
  password_digest: <%= User.digest('password') %>
lana:
  name: Lana Kane
  email: [email protected]
  password_digest: <%= User.digest('password') %>
malory:
  name: Malory Archer
  email: [email protected]
  password_digest: <%= User.digest('password') %>
<% 30.times do |n| %>
user_<%= n %>:
  name:  <%= "User #{n}" %>
  email: <%= "user-#{n}@example.com" %>
  password_digest: <%= User.digest('password') %>
<% end %> 
Generate integration tests to write tests for index pages
$ rails generate integration_test users_index
      invoke  test_unit
      create    test/integration/users_index_test.rb
And test/integration/users_index_test.rb
require 'test_helper'
class UsersIndexTest < ActionDispatch::IntegrationTest
  def setup
    @user = users(:michael)
  end
  test "index including pagination" do
    log_in_as(@user)
    get users_path
    assert_template 'users/index'
    assert_select 'div.pagination'
    User.paginate(page: 1).each do |user|
      assert_select 'a[href=?]', user_path(user), text: user.name
    end
  end
end
rails t
Finished in 2.099836s, 16.6680 runs/s, 0.0000 assertions/s.
35 runs, 0 assertions, 0 failures, 35 errors, 0 skips
Looking at the above picture, the indentation is off (lana: on line 11), but this seems to be the cause.
Apparently, if there is any deviation, it will not be treated as a column and an error will occur.
Also, all tests fail
It is because the pre-fixture data is read in the pre-processing of each test.
Even so, it's hard to be crushed for 5 hours with this one deviation.
Recommended Posts