Skip to content

Check need_auto_run= method is defined also #1350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/rspec/rails/adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@

module RSpec
module Rails
def self.disable_testunit_autorun
# `Test::Unit::AutoRunner.need_auto_run=` was introduced to the test-unit
# gem in version 2.4.9. Previous to this version `Test::Unit.run=` was
# used. The implementation of test-unit included with Ruby has neither
# method.
if defined?(Test::Unit::AutoRunner.need_auto_run = ())
Test::Unit::AutoRunner.need_auto_run = false
elsif defined?(Test::Unit.run = ())
Test::Unit.run = false
end
end
private_class_method :disable_testunit_autorun

if ::Rails::VERSION::STRING >= '4.1.0'
if defined?(Kernel.gem)
gem 'minitest'
Expand Down Expand Up @@ -37,7 +50,7 @@ module Rails
# date). If so, we turn the auto runner off.
require 'test/unit'
require 'test/unit/assertions'
Test::Unit::AutoRunner.need_auto_run = false if defined?(Test::Unit::AutoRunner)
disable_testunit_autorun
rescue LoadError => e
raise LoadError, <<-ERR.squish, e.backtrace
Ruby 2.2+ has removed test/unit from the core library. Rails
Expand All @@ -62,7 +75,7 @@ module Rails
require 'test/unit/assertions'
end
# Turn off test unit's auto runner for those using the gem
Test::Unit::AutoRunner.need_auto_run = false if defined?(Test::Unit::AutoRunner)
disable_testunit_autorun
# Constant aliased to either Minitest or TestUnit, depending on what is
# loaded.
Assertions = Test::Unit::Assertions
Expand Down