diff --git a/lib/simplecov/command_guesser.rb b/lib/simplecov/command_guesser.rb index bc949ffd..6915fcc3 100644 --- a/lib/simplecov/command_guesser.rb +++ b/lib/simplecov/command_guesser.rb @@ -14,12 +14,12 @@ class << self attr_accessor :original_run_command def guess - from_env || from_command_line_options || from_defined_constants + [from_command_line_options || from_defined_constants, parallel_data].compact.join(" ") end private - def from_env + def parallel_data # If being run from inside parallel_tests set the command name according to the process number return unless ENV["PARALLEL_TEST_GROUPS"] && ENV["TEST_ENV_NUMBER"] diff --git a/spec/command_guesser_spec.rb b/spec/command_guesser_spec.rb index 9817f3f2..2e86f0c5 100644 --- a/spec/command_guesser_spec.rb +++ b/spec/command_guesser_spec.rb @@ -45,4 +45,11 @@ subject.original_run_command = "some_arbitrary_command with arguments" expect(subject.guess).to eq("RSpec") end + + it "appends parallel data" do + subject.original_run_command = "/some/path/spec/foo.rb" + expect(ENV).to receive(:[]).with("TEST_ENV_NUMBER").at_least(:once).and_return("1") + expect(ENV).to receive(:[]).with("PARALLEL_TEST_GROUPS").at_least(:once).and_return("2") + expect(subject.guess).to eq("RSpec (1/2)") + end end