<!-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?
<!-Edit title and anchor name->
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.
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.
-Ruby on Rails Tutorial Chapter 3 -Wai no Brain -There were others, but I forgot
Recommended Posts