Ruby on RailsをDockerでTest実行時DRb::DRbRemoteError:でハマった。

IT
おつかれさまです。
タイトル通り、Ruby on RailsをDockerでTest実行時エラーになってしまいハマりました。

エラー内容

src>test>controllers>user_controller_test.rbに以下のテストを書いて実行したところ
require "test_helper"

class UsersControllerTest < ActionDispatch::IntegrationTest
  test "the truth" do    
    assert false
  end
end
E

Error:
UsersControllerTest#test_the_truth:
DRb::DRbRemoteError: Expected false to be truthy. (Minitest::Assertion)
test/controllers/users_controller_test.rb:5:in `block in <class:UsersControllerTest>'
Failure:を期待しているのにエラーになってしまう。。。

原因

docker-compose.ymlにて環境変数

RAILS_ENVをdevelopmentに固定してしまっていたのが原因でした。
#RAILS_ENV: development #ローカル起動時はRAILS_ENVがdevelopmentになるように設定
#↓のようにFREE状態にする
RAILS_ENV:
上記で解消しました。
# Running:

test
F

Failure:
UsersControllerTest#test_the_truth [/app/test/controllers/users_controller_test.rb:6]:
Expected false to be truthy.


rails test test/controllers/users_controller_test.rb:4

Finished in 1.409053s, 0.7097 runs/s, 0.7097 assertions/s.
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
あー時間かかった😭
よし次々!

コメント

タイトルとURLをコピーしました