lib/minitest-chef-handler.rb in minitest-chef-handler-0.2.0 vs lib/minitest-chef-handler.rb in minitest-chef-handler-0.3.0

- old
+ new

@@ -13,19 +13,34 @@ def report # do not run tests if chef failed return if failed? runner = Runner.new(run_status) - runner._run(miniunit_options) + + if custom_runner? + runner._run(miniunit_options) + else + runner.run(miniunit_options) + end end private + def miniunit_options options = [] options << ['-n', @options[:filter]] if @options[:filter] options << "-v" if @options[:verbose] options << ['-s', @options[:seed]] if @options[:seed] options.flatten + end + + # Before Minitest 2.1.0 Minitest::Unit called `run` because the custom runners support was poorly designed. + # See: https://github.com/seattlerb/minitest/commit/6023c879cf3d5169953ee929343b679de4a48bbc + # + # Using this workaround we still allow to use any other runner with the test suite for versions greater than 2.1.0. + # If the test suite doesn't use any chef injection capability it still can be ran with the default Minitest runner. + def custom_runner? + Gem::Version.new(MiniTest::Unit::VERSION) >= Gem::Version.new('2.1.0') end end class Runner < MiniTest::Unit attr_reader :run_status