From 17648d78c28f68ab8278c242eced6019582c5cc0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 16 Jun 2022 15:40:50 +0100 Subject: [PATCH] Loading minitest without initializing the plugin should work --- lib/minitest/buildkite_collector_plugin.rb | 2 +- .../minitest_plugin/without_plugin_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 spec/test_collector/minitest_plugin/without_plugin_spec.rb diff --git a/lib/minitest/buildkite_collector_plugin.rb b/lib/minitest/buildkite_collector_plugin.rb index 0667473..0819078 100644 --- a/lib/minitest/buildkite_collector_plugin.rb +++ b/lib/minitest/buildkite_collector_plugin.rb @@ -1,6 +1,6 @@ module Minitest def self.plugin_buildkite_collector_init(options) - if Buildkite::TestCollector.respond_to?(:uploader) + if defined?(Buildkite::TestCollector::MinitestPlugin) && Buildkite::TestCollector.respond_to?(:uploader) self.reporter << Buildkite::TestCollector::MinitestPlugin::Reporter.new(options[:io], options) end end diff --git a/spec/test_collector/minitest_plugin/without_plugin_spec.rb b/spec/test_collector/minitest_plugin/without_plugin_spec.rb new file mode 100644 index 0000000..b87851e --- /dev/null +++ b/spec/test_collector/minitest_plugin/without_plugin_spec.rb @@ -0,0 +1,9 @@ +require "minitest" + +RSpec.describe "don’t break minitest when the plugin isn’t loaded" do + describe "running minitest" do + it "should not raise an error" do + expect { Minitest.run }.not_to raise_error + end + end +end