Sha256: 3ace3eca70f9886f436170b997b8234397ea899a65f9359461db0481a251f39a

Contents?: true

Size: 1.39 KB

Versions: 38

Compression:

Stored size: 1.39 KB

Contents

if ENV['COVERAGE'] and Kernel.respond_to? :caller_locations
  require 'cistern/coverage'

  SimpleCov.at_exit do
    puts "Adding cistern coverage data"

    result = SimpleCov.result

    models = Ey::Core::Client.constants.map {|c| Ey::Core::Client.const_get c }.select {|c| c.is_a? Class}.select {|c| c.superclass == Ey::Core::Model }

    models.each do |m|
      coverage_details = []

      coverage_details += m.attributes.values.select {|opts| opts[:coverage_hits] } rescue []
      coverage_details += m.associations.values.select {|opts| opts[:coverage_hits] } rescue []

      coverage_details.each do |options|
        unless result_file = result.files.find {|f| f.filename == options[:coverage_file] }
          raise "Coverage failed, couldn't find file '#{file}' in the coverage report"
        end

        # Use the actual calls to the attribute reader as the coverage metric
        result_file.line(options[:coverage_line]).instance_variable_set(:@coverage, options[:coverage_hits])
      end
    end

    result.format!
  end

  CodeClimate::TestReporter.start
  SimpleCov.start do
    add_filter 'spec'

    add_group 'Collections', 'lib/ey-core/collections'
    add_group 'Models', 'lib/ey-core/models'
    add_group 'Requests', 'lib/ey-core/requests'
  end
elsif ENV['COVERAGE']
  warn <<-WARN
Coverage reporting skipped.
This ruby version lacks necessary method Kernel.caller_locations"
  WARN
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
ey-core-3.6.4 spec/support/coverage.rb
ey-core-3.6.3 spec/support/coverage.rb
ey-core-3.6.1 spec/support/coverage.rb
groove-ey-core-3.6.3 spec/support/coverage.rb
groove-ey-core-3.6.2 spec/support/coverage.rb
groove-ey-core-3.6.1 spec/support/coverage.rb
ey-core-3.5.0 spec/support/coverage.rb
ey-core-3.4.4 spec/support/coverage.rb
ey-core-3.4.2 spec/support/coverage.rb
ey-core-3.4.1 spec/support/coverage.rb
ey-core-3.4.0 spec/support/coverage.rb
ey-core-3.3.1 spec/support/coverage.rb
ey-core-3.3.0 spec/support/coverage.rb
ey-core-3.2.6 spec/support/coverage.rb
ey-core-3.2.5 spec/support/coverage.rb
ey-core-3.2.4 spec/support/coverage.rb
ey-core-3.2.3 spec/support/coverage.rb
ey-core-3.2.2 spec/support/coverage.rb
ey-core-3.2.1 spec/support/coverage.rb
ey-core-3.2.0 spec/support/coverage.rb