Skip to content

Rails 8.1 conflict when using shoulda-context 2.0.0, but is fixed by 3.0.0rc1 #109

@kanejamison

Description

@kanejamison

I started seeing the following error in CI after upgrading to Rails 8.1:

When running tests with shoulda-context 2.0.0 on Rails 8.1, test failures trigger a NameError due to upstream changes to how Rails::TestUnitReporter defines the executable attribute.

We started seeing this on CI failures:

# Known flakey test occurs here, followed by:

/home/runner/work/appname/appname/vendor/bundle/ruby/3.4.0/gems/shoulda-context-2.0.0/lib/shoulda/context/rails_test_unit_reporter_patch.rb:16:in 'Rails::TestUnitReporter#format_rerun_snippet': undefined local variable or method 'executable' for an instance of Rails::TestUnitReporter (NameError)

      "#{executable} #{relative_path_for(location)}:#{line}"
         ^^^^^^^^^^
	from /home/runner/work/appname/appname/vendor/bundle/ruby/3.4.0/gems/railties-8.1.1/lib/rails/test_unit/reporter.rb:33:in 'Rails::TestUnitReporter#record'
	from /home/runner/work/appname/appname/vendor/bundle/ruby/3.4.0/gems/minitest-5.26.0/lib/minitest.rb:1010:in 'block in Minitest::CompositeReporter#record'
	from /home/runner/work/appname/appname/vendor/bundle/ruby/3.4.0/gems/minitest-5.26.0/lib/minitest.rb:1009:in 'Array#each'
	from /home/runner/work/appname/appname/vendor/bundle/ruby/3.4.0/gems/minitest-5.26.0/lib/minitest.rb:1009:in 'Minitest::CompositeReporter#record'
... etc

Then I realized shoulda-context 3.0.0.rc1 was available and seems to fix this when it deletes lib/shoulda/context/rails_test_unit_reporter_patch.rb here:

v2.0.0...v3.0.0.rc1#diff-78e53d662d5a955b67bc61f743e1ab39615e84b3b11e469af0857031ab48c186

I have switched my gemfile from calling shoulda to calling each gem separately and the issue is resolved after running CI with a purposely failing test.

old:

  gem "shoulda"

new:

  gem "shoulda-context", "~> 3.0.0.rc1"
  gem "shoulda-matchers"

So anyways, long story short I think the issue is fixed but it might merit a full release on 3.0.0 and updated gemspec on shoulda wrapper gem.

Thanks for maintaining!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions