Module: SimpleCov

### Home Classes Methods

### In Files

- lib/simplecov.rb
- lib/simplecov/command_guesser.rb
- lib/simplecov/configuration.rb
- lib/simplecov/exit_codes.rb
- lib/simplecov/file_list.rb
- lib/simplecov/filter.rb
- lib/simplecov/formatter.rb
- lib/simplecov/formatter/multi_formatter.rb
- lib/simplecov/formatter/simple_formatter.rb
- lib/simplecov/last_run.rb
- lib/simplecov/merge_helpers.rb
- lib/simplecov/profiles.rb
- lib/simplecov/railtie.rb
- lib/simplecov/result.rb
- lib/simplecov/result_merger.rb
- lib/simplecov/source_file.rb
- lib/simplecov/version.rb

### Namespace

- MODULE SimpleCov::ArrayMergeHelper
- MODULE SimpleCov::CommandGuesser
- MODULE SimpleCov::Configuration
- MODULE SimpleCov::ExitCodes
- MODULE SimpleCov::Formatter
- MODULE SimpleCov::HashMergeHelper
- MODULE SimpleCov::LastRun
- MODULE SimpleCov::ResultMerger
- MODULE SimpleCov::VERSION
- CLASS SimpleCov::ArrayFilter
- CLASS SimpleCov::BlockFilter
- CLASS SimpleCov::FileList
- CLASS SimpleCov::Filter
- CLASS SimpleCov::Profiles
- CLASS SimpleCov::Railtie
- CLASS SimpleCov::Result
- CLASS SimpleCov::SourceFile
- CLASS SimpleCov::StringFilter

### Methods

- ::filtered
- ::grouped
- ::load_adapter
- ::load_profile
- ::result
- ::result?
- ::start
- ::usable?

### Class/Module Index

Quicksearch

- SimpleCov
- SimpleCov::ArrayFilter
- SimpleCov::ArrayMergeHelper
- SimpleCov::BlockFilter
- SimpleCov::CommandGuesser
- SimpleCov::Configuration
- SimpleCov::ExitCodes
- SimpleCov::FileList
- SimpleCov::Filter
- SimpleCov::Formatter
- SimpleCov::Formatter::MultiFormatter
- SimpleCov::Formatter::SimpleFormatter
- SimpleCov::HashMergeHelper
- SimpleCov::LastRun
- SimpleCov::Profiles
- SimpleCov::Railtie
- SimpleCov::Result
- SimpleCov::ResultMerger
- SimpleCov::SourceFile
- SimpleCov::SourceFile::Line
- SimpleCov::StringFilter
- SimpleCov::VERSION
- Coverage

No matching classes.

# SimpleCov

Helper that tries to find out what test suite is running (for SimpleCov.command_name)

Bundles the configuration options used for SimpleCov. All methods defined here are usable from SimpleCov directly. Please check out SimpleCov documentation for further info.

An array of SimpleCov SourceFile instances with additional collection helper methods for calculating coverage across them etc.

A ridiculously simple formatter for SimpleCov results.

Profiles are SimpleCov configuration procs that can be easily loaded using SimpleCov.start :rails and defined using

    SimpleCov.profiles.define :foo do
      # SimpleCov configuration here, same as in  SimpleCov.configure
    end

Singleton that is responsible for caching, loading and merging SimpleCov::Results into a single result for coverage analysis based upon multiple test suites.

### Constants

VERSION

### Attributes

pid[RW]
running[RW]

### Public Class Methods

filtered(files) click to toggle source

Applies the configured filters to the given array of SimpleCov::SourceFile items

    # File lib/simplecov.rb, line 80
    def filtered(files)
      result = files.clone
      filters.each do |filter|
        result = result.reject { |source_file| filter.matches?(source_file) }
      end
      SimpleCov::FileList.new result
    end

grouped(files) click to toggle source

Applies the configured groups to the given array of SimpleCov::SourceFile items

    # File lib/simplecov.rb, line 91
    def grouped(files)
      grouped = {}
      grouped_files = []
      groups.each do |name, filter|
        grouped[name] = SimpleCov::FileList.new(files.select { |source_file| filter.matches?(source_file) })
        grouped_files += grouped[name]
      end
      if groups.length > 0 && (other_files = files.reject { |source_file| grouped_files.include?(source_file) }).length > 0
        grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
      end
      grouped
    end

load_adapter(name) click to toggle source

    # File lib/simplecov.rb, line 111
    def load_adapter(name)
      warn "method load_adapter is deprecated. use load_profile instead"
      load_profile(name)
    end

load_profile(name) click to toggle source

Applies the profile of given name on SimpleCov configuration

    # File lib/simplecov.rb, line 107
    def load_profile(name)
      profiles.load(name)
    end

result() click to toggle source

Returns the result for the current coverage run, merging it across test suites from cache using SimpleCov::ResultMerger if use_merging is activated (default)

    # File lib/simplecov.rb, line 55
    def result
      @result ||= SimpleCov::Result.new(Coverage.result) if running
      # If we're using merging of results, store the current result
      # first, then merge the results and return those
      if use_merging
        SimpleCov::ResultMerger.store_result(@result) if @result
        return SimpleCov::ResultMerger.merged_result
      else
        return @result if defined? @result
      end
    ensure
      self.running = false
    end

result?() click to toggle source

Returns nil if the result has not been computed Otherwise, returns the result

    # File lib/simplecov.rb, line 73
    def result?
      defined?(@result) && @result
    end

start(profile = nil, &block) click to toggle source

Sets up SimpleCov to run against your project. You can optionally specify a profile to use as well as configuration with a block:

    SimpleCov.start
     OR
    SimpleCov.start 'rails' # using rails profile
     OR
    SimpleCov.start do
      add_filter 'test'
    end
      OR
    SimpleCov.start 'rails' do
      add_filter 'test'
    end

Please check out the RDoc for SimpleCov::Configuration to find about available config options

    # File lib/simplecov.rb, line 36
    def start(profile = nil, &block)
      if SimpleCov.usable?
        load_profile(profile) if profile
        configure(&block) if block_given?
        @result = nil
        self.running = true
        self.pid = Process.pid
        Coverage.start
      else
        warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
        warn "Starting with SimpleCov 1.0.0, even no-op compatibility with Ruby <= 1.8 will be entirely dropped."
        false
      end
    end

usable?() click to toggle source

Checks whether we're on a proper version of Ruby (likely 1.9+) which provides coverage support

    # File lib/simplecov.rb, line 120
    def usable?
      return @usable if defined?(@usable) && !@usable.nil?

      @usable = begin
        require "coverage"
        require "simplecov/jruby_fix"
        true
      rescue LoadError
        false
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.