[Ruby on Rails Tutorial] Error in the test in Chapter 3

[Ruby on Rails Tutorial] Error in the test in Chapter 3

<!-Description the beginning and outline-> When I tried "3.3.1 First Test" in Chapter 3 of the Ruby on Rails Tutorial, an error occurred, and the BGM of the Liar Game flowed in my brain and collapsed from my knees and went to bed. Also, in the code of this article, the User name is completely visible, but it is the same as the name used in Qiita, so it should be okay. It would be so?

table of contents

<!-Edit title and anchor name->

  1. What kind of error?
  2. What is the solution?
  3. References

<!-Each chapter->

What kind of error?

The following error occurs.

Terminal

PS C:\Users\right\Desktop\Web\Ruby\rails_tutorial\sample_app> rails test
Run options: --seed 4233

# Running:

E

Error:
StaticPagesControllerTest#test_should_get_help:
ActionView::Template::Error: Permission denied @ rb_file_s_rename - (C:/661900.45188.508323, C:/Users/right/Desktop/Web/Ruby/rails_tutorial/sample_app/tmp/cache/assets/sprockets/v4.0.0/jm/jmKa6krLovmtBf-DxAwKf051KFbzekTxfeLnbW5-3lU.cache)
    app/views/layouts/application.html.erb:9
    test/controllers/static_pages_controller_test.rb:10:in `block in <class:StaticPagesControllerTest>'


rails test test/controllers/static_pages_controller_test.rb:9

.

Finished in 7.447825s, 0.2685 runs/s, 0.1343 assertions/s.
2 runs, 1 assertions, 0 failures, 1 errors, 0 skips

Try to read the error statement. I don't do that because it's a hassle in this article. No, I actually did it, but I forgot it because it was yesterday. The poster's brain is volatile memory. Write only the method that was solved by doing it concretely.

What is the solution?

The first thing that was wrong was the following "fix this" part. By the way, to be precise, this is not the bad one. If you test the test code one by one, it will be a smooth success (GREEN). In other words, it is Rails that causes an error by performing parallel processing that is doing bad things.

system>test_helper.rb


ENV['RAILS_ENV'] ||= 'test'
require_relative "../config/environment"
require "rails/test_help"

class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  parallelize(workers: :number_of_processors, with: :threads) #← I'll fix this

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

system>test_helper.rb


  parallelize(workers: 1) #← Do this

I don't even know the meaning of the code there. However, it's probably something that will be processed in parallel. Maybe I don't know.

When I ran the test again, it was very successful. Here, he screams about when he won the World Cup.

It took me 3 hours to resolve this error! !! !! !! !! !! !! !! !!

References

-Ruby on Rails Tutorial Chapter 3 -Wai no Brain -There were others, but I forgot

Recommended Posts

[Ruby on Rails Tutorial] Error in the test in Chapter 3
Things to remember and concepts in the Ruby on Rails tutorial
"" Application.js "is not present in the asset pipeline" error in Ruby on Rails
[Rails Tutorial Chapter 4] Rails-flavored Ruby
Cloud IDE: Heroku couldn't be installed in the Ruby on Rails tutorial
How to resolve errors that occur in the "Ruby on Rails" integration test
[Ruby on Rails] Rails tutorial Chapter 14 Summary of how to implement the status feed
[Ruby On Rails] Error in test using RSpec MySQL client is not connected
Ruby on Rails Japanese-English support i18n
[Ruby on Rails] Quickly display the page title in the browser
rails tutorial Chapter 6
[Ruby on Rails] View test with RSpec
Rails tutorial test
Understand code coverage with Rspec, the Ruby on Rails test framework
part of the syntax of ruby ​​on rails
rails tutorial Chapter 1
Ruby on Rails in Visual Studio Codespaces
[Ruby on Rails] Controller test with RSpec
rails tutorial Chapter 7
rails tutorial Chapter 5
rails tutorial Chapter 10
rails tutorial Chapter 9
[Ruby on Rails] Model test with RSpec
rails tutorial Chapter 8
I summarized the flow until implementing simple_calendar in Ruby on Rails.
Beginners create portfolio in Ruby on Rails
[For beginners] Build the environment for Ruby on Rails Tutorial 4th Edition (Rails 5.1) in less than an hour!
How to debug the processing in the Ruby on Rails model only on the console
[Cloud9] Yay! You ’re on Rails! Is not displayed in the rails tutorial
I rewrote the Rails tutorial test with RSpec
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 6
[Ruby on Rails] How to display error messages
[Ruby on Rails] Until the introduction of RSpec
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 3
When the Ruby on Rails terminal rolls back
Recommendation of Service class in Ruby on Rails
Publish the app made with ruby on rails
Rails new in Ruby on Rails ~ Memorandum until deployment 2
Introducing Rspec, a Ruby on Rails test framework
Rails new in Ruby on Rails ~ Memorandum until deployment 1
(Ruby on Rails6) Creating data in a table
Determine the current page with Ruby on Rails
[Ruby on Rails] How to install Bootstrap in Rails
[Ruby on Rails] Individual display of error messages
Chapter 4 Rails Flavored Ruby
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Test run on rails
Rails Tutorial Chapter 3 Learning
Ruby on Rails Elementary
Ruby on Rails basics
Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 4 Learning
Ruby On Rails Association
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Chapter 8 Notes
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
(Giri) A local government employee in his twenties works on a Rails tutorial [Chapter 11]