前提・実現したいこと
Ruby on Railsにてコントローラのテストを行った際に表示された下記のエラーメッセージを解除したいです。
発生している問題・エラーメッセージ
usernoMacBook-Pro:test user$ rake test test/controllers/articles_controller_test.rb (in /Users/user/Documents/Atom/Ruby on Rails/asagao) Run options: --seed 57752 # Running: ..............Traceback (most recent call last): 11: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/minitest-5.14.0/lib/minitest.rb:68:in `block in a utorun' 10: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/minitest-5.14.0/lib/minitest.rb:138:in `run' 9: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:74:in `start' 8: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:74:in `map' 7: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:74:in `each' 6: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:74:in `times' 5: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:75:in `block in start' 4: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:75:in `fork' 3: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:94:in `block (2 levels) in start' 2: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:97:in `rescue in block (2 levels) in start' 1: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/ parallelization.rb:97:in `each' /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/parallelization.r b:98:in `block (3 levels) in start': undefined method `exception=' for #<Minitest::UnexpectedError: Unexpected exception> (NoMethodErro r) Did you mean? exception Traceback (most recent call last): 2: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/minitest-5.14.0/lib/minitest.rb:68:in `block in au torun' 1: from /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/minitest-5.14.0/lib/minitest.rb:145:in `run' /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/testing/parallelization.r b:118:in `shutdown': Queue not empty, but all workers have finished. This probably means that a worker crashed and 1 tests were missed. (RuntimeError)
該当のソースコード
以下のテストを走らせました。
Ruby
1require 'test_helper' 2 3class ArticlesControllerTest < ActionController::TestCase 4 test "index" do 5 5.times { FactoryGirl.create(:article) } 6 get :index 7 assert_response :success 8 assert_equal 5, assigns(:articles).count 9 end 10 11 test "show" do 12 article = FactoryGirl.create(:article, expired_at: nil) 13 get :show, params: { id: article.id } 14 assert_response :success 15 end 16 17 test "new" do 18 get :new 19 assert_response :success 20 end 21 22 test "edit" do 23 article = FactoryGirl.create(:article) 24 get :edit, params: { id: article.id } 25 assert_response :success 26 end 27 28 test "create" do 29 post :create, params: { article: FactoryGirl.attributes_for(:article) } 30 article = Article.order(:id).last 31 assert_redirected_to article 32 end 33 34 test "update" do 35 article = FactoryGirl.create(:article) 36 patch :update, params: { id: article.id, article: FactoryGirl.attributes_for(:article) } 37 assert_redirected_to article 38 end 39 40 test "fail to create" do 41 attrs = FactoryGirl.attributes_for(:article, title: "") 42 post :create, params: { article: attrs } 43 assert_response :success 44 assert_template "new" 45 end 46 47 test "fail to update" do 48 attrs = FactoryGirl.attributes_for(:article, body: "") 49 article = FactoryGirl.create(:article) 50 put :update, params: { id: article.id, article: attrs } 51 assert_response :success 52 assert_template "edit" 53 end 54end 55
試したこと
こちらに書かれたことは試しましたが、エラーメッセージは変わらぬままでした。
補足情報(FW/ツールのバージョンなど)
Rails 6.0.2.1
Ruby 2.5.0
Minitest (5.14.0, 5.10.3)
articlesのDBの定義は以下です。
db
1class CreateArticles < ActiveRecord::Migration[6.0] 2 def change 3 create_table :articles do |t| 4 t.string :title, null: false #タイトル 5 t.text :body, null: false #本文 6 t.datetime :released_at, null: false #掲載開始日時 7 t.datetime :expired_at #掲載終了日時 8 t.boolean :member_only, null: false, default: false #会員のみフラグ 9 t.timestamps null: false 10 end 11 end 12end
皆さまからの質問などは分からないなりに調べてご返信致します。何か不足した情報などがありましたら教えて頂ければと思います。何卒宜しくお願い致します。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/02/12 03:53