I read this similar post. Inconsistent Rails Test Results. It only has one response and it doesn't help me.
I've been following along with this new book called Agile Web Development with Rails 6. And the author runs these tests and they don't work for me.
Here's what I did.
I created a new rails project using new rails test
and then ran rails generate scaffold Product title:string description:text image_url:string price:decimal
. This is the command that the author uses. I then run rails db:migrate RAILS_ENV=test
and then am ready to run rails test
.
After doing that I get this response in the console. 7 runs, 5 assertions, 0 failures, 3 errors, 0 skips
Here are the errors.
Error: ProductsControllerTest#test_should_get_index: ActionView::Template::Error: Permission denied @ rb_file_s_rename - (C:/Users/Client/Desktop/Ruby on Rails/tests/tmp/cache/assets/sprockets/v4.0.0/-T/-TZMQrMJrqe1bey8hRhmqKVmncCU8rFfTfOziZyMSMQ.cache.74410620.20908.613522, C:/Users/Client/Desktop/Ruby on Rails/tests/tmp/cache/assets/sprockets/v4.0.0/-T/-TZMQrMJrqe1bey8hRhmqKVmncCU8rFfTfOziZyMSMQ.cache)
Error: ProductsControllerTest#test_should_show_product: ActionView::Template::Error: Permission denied @ rb_file_s_rename - (C:/Users/Client/Desktop/Ruby on Rails/tests/tmp/cache/assets/sprockets/v4.0.0/HM/HMwQEAOlQlZbn_VGqaBmumzU5MudrUMOA7mZ9lf-I3U.cache.73876560.20908.130802, C:/Users/Client/Desktop/Ruby on Rails/tests/tmp/cache/assets/sprockets/v4.0.0/HM/HMwQEAOlQlZbn_VGqaBmumzU5MudrUMOA7mZ9lf-I3U.cache) app/views/layouts/application.html.erb:8 test/controllers/products_controller_test.rb:27:in `block in class:ProductsControllerTest'
Error: ProductsControllerTest#test_should_destroy_product: ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked app/controllers/products_controller.rb:57:in destroy' test/controllers/products_controller_test.rb:43:in
block (2 levels) in class:ProductsControllerTest' test/controllers/products_controller_test.rb:42:in `block in class:ProductsControllerTest'
The inconsistency is that my results vary, here are some of them
7 runs, 7 assertions, 0 failures, 2 errors, 0 skips
7 runs, 4 assertions, 0 failures, 4 errors, 0 skips
7 runs, 8 assertions, 0 failures, 1 errors, 0 skips
And once I had 0 failures and 0 errors. I am absolutely new to Ruby on Rails so any help is appreciated. Also, I have tried running bundle exec rake db:test:prepare
which I read in the post I linked at the top. That didn't help me.
Aucun commentaire:
Enregistrer un commentaire