rails tutorial fighting notes Ⅲ

environment

ruby 2.6.3 rails 6.0.3 AWS cloud9

10.3.4 Testing the user list

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

solution

D69E163E-D398-4F4D-9B9B-0A4E2BC61C91.jpeg 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

rails tutorial fighting notes Ⅲ
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 8 Notes
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial Chapter 6
Rails tutorial test
rails tutorial Chapter 1
Rails tutorial memorandum 1
Rails tutorial memorandum 2
rails tutorial Chapter 5
rails tutorial Chapter 10
rails tutorial Chapter 9
rails tutorial Chapter 8
Start Rails Tutorial
[Beginner] Rails Tutorial
html & rails notes
Rails Tutorial cheat sheet
Rails Tutorial Chapter 3 Learning
[Rails] Learning with Rails tutorial
Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Chapter 4 Learning
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
11.1 AccountActivations Resources: Rails Tutorial Notes-Chapter 11
Rails Tutorial Records and Memorandum # 0
Rails Tutorial (4th Edition) Summary
[Rails] Implementation of tutorial function
[Rails] New app creation --Notes--
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
Piped together grep ?: Rails Tutorial Notes--Chapter 8
[Rails Tutorial Chapter 5] Create a layout
rails tutorial chapter 10 summary (for self-learning)
Rails Tutorial (4th Edition) Memo Chapter 6
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 7
Rails Tutorial 6th Edition Learning Summary Chapter 4
Policy-setting fighting notes for running outdated applets
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
What is follow_redirect! Following ?: Rails Tutorial Memorandum-Chapter 7
[Rails Struggle/Rails Tutorial] Summary of Heroku commands
Rails Tutorial 6th Edition Learning Summary Chapter 5
How to use MySQL in Rails tutorial
Notes on using FCM with Ruby on Rails
Testing for Error Messages: Rails Tutorial Notes-Chapter 7
Rails Tutorial 6th Edition Learning Summary Chapter 2
Rails Tutorial 6th Edition Learning Summary Chapter 3
Rails tutorial (6th edition) Follow/unfollow background operation
Rails validation and null: false Personal notes
Rails Tutorial 6th Edition Learning Summary Chapter 8