Sha256: 515124cc782ae0b863a6bc382d134ff46cbaa6b62f72bff6ea44b6f8047e6b37

Contents?: true

Size: 1.47 KB

Versions: 44

Compression:

Stored size: 1.47 KB

Contents

#
# Helper that tries to find out what test suite is running (for SimpleCov.command_name)
#
module SimpleCov::CommandGuesser
  class << self
    # Storage for the original command line call that invoked the test suite.
    # This has got to be stored as early as possible because i.e. rake and test/unit 2
    # have a habit of tampering with ARGV, which makes i.e. the automatic distinction
    # between rails unit/functional/integration tests impossible without this cached
    # item.
    attr_accessor :original_run_command
    
    def guess
      from_command_line_options || from_defined_constants
    end
    
    private
    
    def from_command_line_options
      case original_run_command
        when /#{'test/functional/'}/
          "Functional Tests"
        when /#{'test/integration/'}/
          "Integration Tests"
        when /#{'test/'}/
          "Unit Tests"
        when /cucumber/, /features/
          "Cucumber Features"
        when /spec/
          "RSpec"
        else
          nil
      end
    end
  
    def from_defined_constants
      # If the command regexps fail, let's try checking defined constants.
      if defined?(RSpec)
        "RSpec"
      elsif defined?(Test::Unit)
        "Unit Tests"
      else
        # TODO: Provide link to docs/wiki article
        warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
        'Unknown Test Framework'
      end
    end
  end
end

Version data entries

44 entries across 34 versions & 6 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-1.0.0 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-1.0.0.beta3 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-1.0.0.beta2 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-1.0.0.beta vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-0.9.1.beta.3 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
devise_sociable-0.1.0 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-0.9.1.beta vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-0.9.0 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/simplecov-0.6.4/lib/simplecov/command_guesser.rb
challah-rolls-0.2.0 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
challah-rolls-0.2.0 vendor/bundle/gems/simplecov-0.6.4/lib/simplecov/command_guesser.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/simplecov-0.6.4/lib/simplecov/command_guesser.rb
challah-0.8.3 vendor/bundle/gems/simplecov-0.6.4/lib/simplecov/command_guesser.rb
challah-0.8.3 vendor/bundle/gems/simplecov-0.7.1/lib/simplecov/command_guesser.rb
simplecov-0.7.1 lib/simplecov/command_guesser.rb