diff --git a/features/config_command_name.feature b/features/config_command_name.feature index a5b5f76f..2b6b5b34 100644 --- a/features/config_command_name.feature +++ b/features/config_command_name.feature @@ -31,3 +31,15 @@ Feature: Custom names for individual test suites | Dreck macht Speck | | I'm in UR Unitz | + Scenario: RSpec auto detection with spec/features + Given SimpleCov for RSpec is configured with: + """ + require 'simplecov' + SimpleCov.start + """ + And a file named "spec/features/foobar_spec.rb" with: + """ + """ + When I open the coverage report generated with `bundle exec rspec spec` + Then the report should be based upon: + | RSpec | diff --git a/lib/simplecov/command_guesser.rb b/lib/simplecov/command_guesser.rb index 4fb8b1fb..7ec1ee6b 100644 --- a/lib/simplecov/command_guesser.rb +++ b/lib/simplecov/command_guesser.rb @@ -11,11 +11,22 @@ class << self attr_accessor :original_run_command def guess - from_command_line_options || from_defined_constants + from_program_name || from_command_line_options || from_defined_constants end private + def from_program_name + case $PROGRAM_NAME + when /\/rspec$/ + "RSpec" + when /\/cucumber$/ + "Cucumber Features" + else + nil + end + end + def from_command_line_options case original_run_command when /#{'test/functional/'}/, /#{'test/{.*?functional.*?}/'}/ @@ -46,4 +57,4 @@ def from_defined_constants end end end -end \ No newline at end of file +end