metaskills / minitest-spec-rails

:bento: Make Rails Use MiniTest::Spec!

Home Page:http://github.com/metaskills/minitest-spec-rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails 6 errors current_server': DRb::DRbServerNotFound (DRb::DRbConnError)

scmx opened this issue Β· comments

πŸ‘‹ Hey, I'm a long time user of this gem.

Today I tried it out with Rails 6 but got some strange drb errors. πŸ€”

The test it fails for is a rails controller test where I've just changed a test-block into describe and it.

require 'test_helper'

class SomeControllerTest < ActionDispatch::IntegrationTest
  describe "some describe" do
    it "does something" do
      ...
ruby/2.5.0/drb/drb.rb:1733:in `current_server': DRb::DRbServerNotFound (DRb::DRbConnError)
.Traceback (most recent call last):
        23: from minitest-5.11.3/lib/minitest.rb:63:in `block in autorun'
        22: from minitest-5.11.3/lib/minitest.rb:133:in `run'
        21: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:74:in `start'
        20: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:74:in `map'
        19: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:74:in `each'
        18: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:74:in `times'
        17: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:75:in `block in start'
        16: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:75:in `fork'
        15: from activesupport-6.0.0/lib/active_support/testing/parallelization.rb:88:in `block (2 levels) in start'
        14: from drb/drb.rb:1139:in `method_missing'
        13: from drb/drb.rb:1159:in `with_friend'
        12: from drb/drb.rb:1140:in `block in method_missing'
        11: from drb/drb.rb:1228:in `open'
        10: from drb/drb.rb:1141:in `block (2 levels) in method_missing'
         9: from drb/drb.rb:1252:in `send_message'
         8: from drb/drb.rb:925:in `send_request'
         7: from drb/drb.rb:613:in `send_request'
         6: from drb/drb.rb:564:in `dump'
         5: from drb/drb.rb:567:in `rescue in dump'
         4: from drb/drb.rb:650:in `make_proxy'
         3: from drb/drb.rb:650:in `new'
         2: from drb/drb.rb:1102:in `initialize'
         1: from drb/drb.rb:1802:in `to_id'
drb/drb.rb:1733:in `current_server': DRb::DRbServerNotFound (DRb::DRbConnError)
Traceback (most recent call last):
        2: from minitest-5.11.3/lib/minitest.rb:63:in `block in autorun'
        1: from minitest-5.11.3/lib/minitest.rb:140:in `run'
activesupport-6.0.0/lib/active_support/testing/parallelization.rb:118:in `shutdown': Queue not empty, but all workers have finished. This probably means that a worker crashed and 2 tests were missed. (RuntimeError)

πŸ€” Wondering if I'm doing something wrong or if this gem isn't compatible with rails 6 yet.

Hey Albert, so sorry for the belated reply. The gem "should" be compatible with Rails v6. I did this PR a few weeks back and all the tests showed green. #95

Have you tracked this down to an issue in the gem or something else? Is this only for controller tests or does it also apply to model tests? Also, are you using a feature of Rails v6 to run parallel tests or is that native now?

I have the exact same problem on a brand new rails 6 app. If I place my tests inside a describe block, I get the error above. But if I only use it blocks, everything is green.

Reducing the numbers of workers to 1 is a temporary fix

class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  parallelize(workers: 1)
end

it only a problem for postgresql databases

As @woller has described, this is happening when parallelize is used with more than 1 worker and describe.

I wanted to provide a failing test, but I'm unable to run the test suite.

A temporary workaround is to copy https://github.com/blowmage/minitest-rails/blob/master/lib/minitest/rails/parallelize.rb.

Closing since this duplicates #94. Open to a PR to fix this issue here now that our master builds are green.

I had this issue in Rails 7 running minitest with require "minitest/spec" added to test_helper.rb and was getting the above error.

Followed tip from @metaskills in #94 to upgrade to v6.0.2.

I explicitly added the current minitest-spec-rails (v6.1.0) to my Gemfile and this resolved the issue for me.