source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/result_merger.rb | Ruby | mit | 4,885 | main | 6,744 | # frozen_string_literal: true
require "json"
module SimpleCov
#
# Singleton that is responsible for caching, loading and merging
# SimpleCov::Results into a single result for coverage analysis based
# upon multiple test suites.
#
module ResultMerger
class << self
# The path to the .resultset.jso... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/last_run.rb | Ruby | mit | 4,885 | main | 556 | # frozen_string_literal: true
require "json"
module SimpleCov
module LastRun
class << self
def last_run_path
File.join(SimpleCov.coverage_path, ".last_run.json")
end
def read
return nil unless File.exist?(last_run_path)
json = File.read(last_run_path)
return n... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/simulate_coverage.rb | Ruby | mit | 4,885 | main | 730 | # frozen_string_literal: true
module SimpleCov
#
# Responsible for producing file coverage metrics.
#
module SimulateCoverage
module_function
#
# Simulate normal file coverage report on
# ruby 2.5 and return similar hash with lines and branches keys
#
# Happens when a file wasn't require... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/result_adapter.rb | Ruby | mit | 4,885 | main | 2,049 | # frozen_string_literal: true
module SimpleCov
#
# Responsible for adapting the format of the coverage result whether it's default or with statistics
#
class ResultAdapter
attr_reader :result
def initialize(result)
@result = result
end
def self.call(*args)
new(*args).adapt
end... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/coverage_violations.rb | Ruby | mit | 4,885 | main | 3,369 | # frozen_string_literal: true
module SimpleCov
# Computes coverage threshold violations for a given result. Shared by
# the exit-code checks and the JSON formatter's `errors` section.
#
# Each method returns an array of violation hashes. All percents are
# rounded via `SimpleCov.round_coverage` so downstream... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/file_list.rb | Ruby | mit | 4,885 | main | 4,219 | # frozen_string_literal: true
module SimpleCov
# An array of SimpleCov SourceFile instances with additional collection helper
# methods for calculating coverage across them etc.
class FileList
include Enumerable
extend Forwardable
def_delegators :@files,
# For Enumerable
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter.rb | Ruby | mit | 4,885 | main | 273 | # frozen_string_literal: true
module SimpleCov
# TODO: Documentation on how to build your own formatters
module Formatter
end
end
require_relative "formatter/simple_formatter"
require_relative "formatter/multi_formatter"
require_relative "formatter/json_formatter" |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/process.rb | Ruby | mit | 4,885 | main | 417 | # frozen_string_literal: true
module Process
class << self
def fork_with_simplecov(&block)
if defined?(SimpleCov) && SimpleCov.running
fork_without_simplecov do
SimpleCov.at_fork.call(Process.pid)
yield if block
end
else
fork_without_simplecov(&block)
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/result.rb | Ruby | mit | 4,885 | main | 3,619 | # frozen_string_literal: true
require "digest/sha1"
require "forwardable"
module SimpleCov
#
# A simplecov code coverage result, initialized from the Hash Ruby's built-in coverage
# library generates (Coverage.result).
#
class Result
extend Forwardable
# Returns the original Coverage.result used fo... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/configuration.rb | Ruby | mit | 4,885 | main | 18,756 | # frozen_string_literal: true
require "fileutils"
require_relative "formatter/multi_formatter"
module SimpleCov
#
# Bundles the configuration options used for SimpleCov. All methods
# defined here are usable from SimpleCov directly. Please check out
# SimpleCov documentation for further info.
#
module Con... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/filter.rb | Ruby | mit | 4,885 | main | 3,760 | # frozen_string_literal: true
module SimpleCov
#
# Base filter class. Inherit from this to create custom filters,
# and overwrite the passes?(source_file) instance method
#
# # A sample class that rejects all source files.
# class StupidFilter < SimpleCov::Filter
# def passes?(source_file)
# fals... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/default_formatter.rb | Ruby | mit | 4,885 | main | 444 | # frozen_string_literal: true
require_relative "formatter/html_formatter"
module SimpleCov
module Formatter
class << self
def from_env(env)
formatters = [SimpleCov::Formatter::HTMLFormatter]
# When running under a CI that uses CodeClimate, JSON output is expected
formatters.push(Si... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/useless_results_remover.rb | Ruby | mit | 4,885 | main | 409 | # frozen_string_literal: true
module SimpleCov
#
# Select the files that related to working scope directory of SimpleCov
#
module UselessResultsRemover
def self.call(coverage_result)
coverage_result.select do |path, _coverage|
path =~ root_regx
end
end
def self.root_regx
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/lines_classifier.rb | Ruby | mit | 4,885 | main | 1,190 | # frozen_string_literal: true
module SimpleCov
# Classifies whether lines are relevant for code coverage analysis.
# Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.
class LinesClassifier
RELEVANT = 0
NOT_RELEVANT = nil
WHITESPACE_LINE = /^\s*$/.freeze
COMMENT... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/exit_codes.rb | Ruby | mit | 4,885 | main | 458 | # frozen_string_literal: true
module SimpleCov
module ExitCodes
SUCCESS = 0
EXCEPTION = 1
MINIMUM_COVERAGE = 2
MAXIMUM_COVERAGE_DROP = 3
end
end
require_relative "exit_codes/exit_code_handling"
require_relative "exit_codes/maximum_coverage_drop_check"
require_relative "exit_codes/minimum_coverage_... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/load_global_config.rb | Ruby | mit | 4,885 | main | 338 | # frozen_string_literal: true
require "etc"
home_dir = (ENV.fetch("HOME", nil) && File.expand_path("~")) || Etc.getpwuid.dir || (ENV.fetch("USER", nil) && File.expand_path("~#{ENV.fetch('USER', nil)}"))
if home_dir
global_config_path = File.join(home_dir, ".simplecov")
load global_config_path if File.exist?(global... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/defaults.rb | Ruby | mit | 4,885 | main | 1,458 | # frozen_string_literal: true
# Load default formatter gem
require "pathname"
require_relative "default_formatter"
require_relative "profiles/root_filter"
require_relative "profiles/test_frameworks"
require_relative "profiles/bundler_filter"
require_relative "profiles/hidden_filter"
require_relative "profiles/rails"
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/source_file.rb | Ruby | mit | 4,885 | main | 13,001 | # frozen_string_literal: true
require "strscan"
module SimpleCov
#
# Representation of a source file including it's coverage data, source code,
# source lines and featuring helpers to interpret that data.
#
class SourceFile
SHEBANG_REGEX = /\A#!/.freeze
RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/profiles.rb | Ruby | mit | 4,885 | main | 908 | # frozen_string_literal: true
module SimpleCov
#
# 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
#
class Profiles <... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/combine.rb | Ruby | mit | 4,885 | main | 786 | # frozen_string_literal: true
module SimpleCov
# Functionally for combining coverage results
#
module Combine
module_function
#
# Combine two coverage based on the given combiner_module.
#
# Combiners should always be called through this interface,
# as it takes care of short-circuiting of... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/coverage_statistics.rb | Ruby | mit | 4,885 | main | 2,206 | # frozen_string_literal: true
module SimpleCov
# Holds the individual data of a coverage result.
#
# This is uniform across coverage criteria as they all have:
#
# * total - how many things to cover there are (total relevant loc/branches)
# * covered - how many of the coverables are hit
# * missed - how ... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/command_guesser.rb | Ruby | mit | 4,885 | main | 2,105 | # frozen_string_literal: true
module SimpleCov
#
# Helper that tries to find out what test suite is running (for SimpleCov.command_name)
#
module CommandGuesser
class << self
# Storage for the original command line call that invoked the test suite.
# This has got to be stored as early as possib... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/combine/results_combiner.rb | Ruby | mit | 4,885 | main | 1,834 | # frozen_string_literal: true
module SimpleCov
module Combine
# There might be reports from different kinds of tests,
# e.g. RSpec and Cucumber. We need to combine their results
# into unified one. This class does that.
# To unite the results on file basis, it leverages
# the combine of lines and... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/combine/lines_combiner.rb | Ruby | mit | 4,885 | main | 1,047 | # frozen_string_literal: true
module SimpleCov
module Combine
#
# Combine two different lines coverage results on same file
#
# Should be called through `SimpleCov.combine`.
module LinesCombiner
module_function
def combine(coverage_a, coverage_b)
acc = coverage_a.size > coverag... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/combine/branches_combiner.rb | Ruby | mit | 4,885 | main | 1,195 | # frozen_string_literal: true
module SimpleCov
module Combine
#
# Combine different branch coverage results on single file.
#
# Should be called through `SimpleCov.combine`.
module BranchesCombiner
module_function
#
# Return merged branches or the existed branch if other is missi... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/combine/methods_combiner.rb | Ruby | mit | 4,885 | main | 729 | # frozen_string_literal: true
module SimpleCov
module Combine
#
# Combine different method coverage results on a single file.
#
# Should be called through `SimpleCov.combine`.
module MethodsCombiner
module_function
#
# Return merged methods or the existing methods if other is mis... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/combine/files_combiner.rb | Ruby | mit | 4,885 | main | 828 | # frozen_string_literal: true
module SimpleCov
module Combine
#
# Handle combining two coverage results for same file
#
# Should be called through `SimpleCov.combine`.
module FilesCombiner
module_function
#
# Combines the results for 2 coverages of a file.
#
# @return... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/profiles/root_filter.rb | Ruby | mit | 4,885 | main | 283 | # frozen_string_literal: true
SimpleCov.profiles.define "root_filter" do
# Exclude all files outside of simplecov root
root_filter = nil
add_filter do |src|
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
src.filename !~ root_filter
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/profiles/rails.rb | Ruby | mit | 4,885 | main | 462 | # frozen_string_literal: true
SimpleCov.profiles.define "rails" do
load_profile "test_frameworks"
add_filter %r{^/config/}
add_filter %r{^/db/}
add_group "Controllers", "app/controllers"
add_group "Channels", "app/channels"
add_group "Models", "app/models"
add_group "Mailers", "app/mailers"
add_group... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/source_file/branch.rb | Ruby | mit | 4,885 | main | 1,915 | # frozen_string_literal: true
module SimpleCov
class SourceFile
#
# Representing single branch that has been detected in coverage report.
# Give us support methods that handle needed calculations.
class Branch
attr_reader :start_line, :end_line, :coverage, :type
def initialize(start_line... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/source_file/method.rb | Ruby | mit | 4,885 | main | 1,016 | # frozen_string_literal: true
module SimpleCov
class SourceFile
# Represents a single method detected in coverage data.
# Provides helpers similar to Branch for coverage status.
class Method
attr_reader :source_file, :coverage, :class_name, :method_name,
:start_line, :start_col, :... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/source_file/line.rb | Ruby | mit | 4,885 | main | 2,417 | # frozen_string_literal: true
module SimpleCov
class SourceFile
# Representation of a single line in a source file including
# this specific line's source code, line_number and code coverage,
# with the coverage being either nil (coverage not applicable, e.g. comment
# line), 0 (line not covered) or ... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/multi_formatter.rb | Ruby | mit | 4,885 | main | 805 | # frozen_string_literal: true
module SimpleCov
module Formatter
class MultiFormatter
module InstanceMethods
def format(result)
formatters.map do |formatter|
formatter.new.format(result)
rescue StandardError => e
warn("Formatter #{formatter} failed with #{... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/html_formatter.rb | Ruby | mit | 4,885 | main | 3,438 | # frozen_string_literal: true
require "erb"
require "fileutils"
require "time"
require_relative "html_formatter/view_helpers"
module SimpleCov
module Formatter
# Generates an HTML coverage report from SimpleCov results.
class HTMLFormatter
VERSION = "0.13.2"
# Only have a few content types, jus... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/json_formatter.rb | Ruby | mit | 4,885 | main | 1,039 | # frozen_string_literal: true
require_relative "json_formatter/result_hash_formatter"
require_relative "json_formatter/result_exporter"
require "json"
module SimpleCov
module Formatter
class JSONFormatter
def initialize(silent: false)
@silent = silent
end
def format(result)
re... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/simple_formatter.rb | Ruby | mit | 4,885 | main | 632 | # frozen_string_literal: true
module SimpleCov
module Formatter
#
# A ridiculously simple formatter for SimpleCov results.
#
class SimpleFormatter
# Takes a SimpleCov::Result and generates a string out of it
def format(result)
output = +""
result.groups.each do |name, file... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/html_formatter/view_helpers.rb | Ruby | mit | 4,885 | main | 2,189 | # frozen_string_literal: true
require "digest/md5"
require "set"
require_relative "coverage_helpers"
module SimpleCov
module Formatter
class HTMLFormatter
# Helper methods used by ERB templates for rendering coverage data.
module ViewHelpers
include CoverageHelpers
def line_status?(... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/html_formatter/coverage_helpers.rb | Ruby | mit | 4,885 | main | 5,488 | # frozen_string_literal: true
module SimpleCov
module Formatter
class HTMLFormatter
# Helpers for rendering coverage bars, cells, and summaries in ERB templates.
module CoverageHelpers
def coverage_bar(pct)
css = coverage_css_class(pct)
width = Kernel.format("%.1f", pct.fl... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/json_formatter/result_hash_formatter.rb | Ruby | mit | 4,885 | main | 4,618 | # frozen_string_literal: true
require_relative "source_file_formatter"
module SimpleCov
module Formatter
class JSONFormatter
class ResultHashFormatter
def initialize(result)
@result = result
end
def format
format_total
format_files
format_gr... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/json_formatter/result_exporter.rb | Ruby | mit | 4,885 | main | 572 | # frozen_string_literal: true
module SimpleCov
module Formatter
class JSONFormatter
class ResultExporter
FILENAME = "coverage.json"
def initialize(result_hash)
@result = result_hash
end
def export
File.open(export_path, "w") do |file|
file <... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/formatter/json_formatter/source_file_formatter.rb | Ruby | mit | 4,885 | main | 1,984 | # frozen_string_literal: true
module SimpleCov
module Formatter
class JSONFormatter
class SourceFileFormatter
def initialize(source_file)
@source_file = source_file
@line_coverage = nil
end
def format
result = line_coverage
result.merge!(bran... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/exit_codes/minimum_overall_coverage_check.rb | Ruby | mit | 4,885 | main | 934 | # frozen_string_literal: true
module SimpleCov
module ExitCodes
class MinimumOverallCoverageCheck
def initialize(result, minimum_coverage)
@result = result
@minimum_coverage = minimum_coverage
end
def failing?
violations.any?
end
def report
violatio... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb | Ruby | mit | 4,885 | main | 1,047 | # frozen_string_literal: true
module SimpleCov
module ExitCodes
class MinimumCoverageByFileCheck
def initialize(result, minimum_coverage_by_file)
@result = result
@minimum_coverage_by_file = minimum_coverage_by_file
end
def failing?
violations.any?
end
def ... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/exit_codes/minimum_coverage_by_group_check.rb | Ruby | mit | 4,885 | main | 1,052 | # frozen_string_literal: true
module SimpleCov
module ExitCodes
class MinimumCoverageByGroupCheck
def initialize(result, minimum_coverage_by_group)
@result = result
@minimum_coverage_by_group = minimum_coverage_by_group
end
def failing?
violations.any?
end
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/exit_codes/maximum_coverage_drop_check.rb | Ruby | mit | 4,885 | main | 957 | # frozen_string_literal: true
module SimpleCov
module ExitCodes
class MaximumCoverageDropCheck
def initialize(result, maximum_coverage_drop)
@result = result
@maximum_coverage_drop = maximum_coverage_drop
end
def failing?
violations.any?
end
def report
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov/exit_codes/exit_code_handling.rb | Ruby | mit | 4,885 | main | 886 | # frozen_string_literal: true
module SimpleCov
module ExitCodes
module ExitCodeHandling
module_function
def call(result, coverage_limits:)
checks = coverage_checks(result, coverage_limits)
failing_check = checks.find(&:failing?)
if failing_check
failing_check.report
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | benchmarks/result.rb | Ruby | mit | 4,885 | main | 629 | # frozen_string_literal: true
require "benchmark/ips"
require "coverage"
Coverage.start
# such meta, many wow
require_relative "../lib/simplecov"
require_relative "../test_projects/faked_project/lib/faked_project"
result = Coverage.result
class MyFormatter
def format(result)
result.files.map do |file|
"#... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test/html_formatter/test_simple_cov-html.rb | Ruby | mit | 4,885 | main | 6,369 | # frozen_string_literal: true
require "helper"
require "coverage_fixtures"
class TestSimpleCovHtml < Minitest::Test
EXPECTED_LINE_COVERAGES = %w[
57.14% 64.28% 66.66% 66.66% 80.00% 80.00%
85.71% 85.71% 85.71% 100.00% 100.00% 100.00%
].freeze
EXPECTED_BRANCH_COVERAGES = %w[
25.00% 25.00% 45.83% 50.0... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test/html_formatter/coverage_fixtures.rb | Ruby | mit | 4,885 | main | 5,830 | # frozen_string_literal: true
# Coverage data fixtures adapted from simplecov's spec/source_file_spec.rb
module CoverageFixtures
BRANCHES_RB = {
"lines" => [1, 1, 1, nil, 1, nil, 1, 0, nil, 1, nil, nil, nil],
"branches" => {
[:if, 0, 3, 4, 3, 21] => {[:then, 1, 3, 4, 3, 10] => 0, [:else, 2, 3, 4, 3, 21... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test/html_formatter/test_view_helpers.rb | Ruby | mit | 4,885 | main | 43,259 | # frozen_string_literal: true
require "English"
require "helper"
require "coverage_fixtures"
require "set"
class TestViewHelpers < Minitest::Test
cover "SimpleCov::Formatter::HTMLFormatter::ViewHelpers#coverage_css_class" if respond_to?(:cover)
def test_coverage_css_class_green
assert_equal "green", formatte... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test/html_formatter/test_formatter.rb | Ruby | mit | 4,885 | main | 24,127 | # frozen_string_literal: true
require "English"
require "helper"
require "coverage_fixtures"
require "tmpdir"
class TestFormatter < Minitest::Test
cover "SimpleCov::Formatter::HTMLFormatter#initialize" if respond_to?(:cover)
def test_initialize_sets_branch_coverage_from_simplecov
f = SimpleCov::Formatter::HT... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/helper.rb | Ruby | mit | 4,885 | main | 447 | # frozen_string_literal: true
require "rspec"
require "stringio"
require "open3"
# loaded before simplecov to also capture parse time warnings
require "support/fail_rspec_on_ruby_warning"
require "simplecov"
SimpleCov.coverage_dir("tmp/coverage")
def source_fixture(filename)
File.join(source_fixture_base_directory... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/useless_results_remover_spec.rb | Ruby | mit | 4,885 | main | 1,067 | # frozen_string_literal: true
require "helper"
describe SimpleCov::UselessResultsRemover do
subject do
SimpleCov::UselessResultsRemover.call(result_set)
end
let(:gem_file_path) { "usr/bin/lib/2.5.0/gems/sample-gem/sample.rb" }
let(:source_path) { source_fixture("app/models/user.rb") }
let(:result_set)... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/result_merger_spec.rb | Ruby | mit | 4,885 | main | 12,041 | # frozen_string_literal: true
require "helper"
require "tempfile"
require "timeout"
describe SimpleCov::ResultMerger do
after do
FileUtils.rm_f(SimpleCov::ResultMerger.resultset_path)
end
let(:resultset1) do
{
source_fixture("sample.rb") => {"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]},
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/file_list_spec.rb | Ruby | mit | 4,885 | main | 1,487 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Result do
subject do
original_result = {
source_fixture("sample.rb") => {
"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
"branches" => {}
},
source_fixture("app/models/user.rb") => {
"lines" => [ni... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/source_file_spec.rb | Ruby | mit | 4,885 | main | 30,389 | # frozen_string_literal: true
require "helper"
describe SimpleCov::SourceFile do
COVERAGE_FOR_SAMPLE_RB = {
"lines" => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, 1, 0, nil, nil, nil],
"branches" => {}
}.freeze
COVERAGE_FOR_SAMPLE_RB_WITH_MORE_LINES = {
"lines" => [nil, 1, 1, 1, nil, nil, 1... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/last_run_spec.rb | Ruby | mit | 4,885 | main | 1,112 | # frozen_string_literal: true
require "helper"
describe SimpleCov::LastRun do
subject { SimpleCov::LastRun }
it "defines a last_run_path" do
expect(subject.last_run_path).to include "tmp/coverage/.last_run.json"
end
it "writes json to its last_run_path that can be parsed again" do
structure = [{"key... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/coverage_statistics_spec.rb | Ruby | mit | 4,885 | main | 2,577 | # frozen_string_literal: true
require "helper"
RSpec.describe SimpleCov::CoverageStatistics do
describe ".new" do
it "retains statistics and computes new ones" do
statistics = described_class.new(covered: 4, missed: 6, omitted: 2, total_strength: 14)
expect(statistics.covered).to eq 4
expect(... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/result_spec.rb | Ruby | mit | 4,885 | main | 7,431 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Result do
context "with a (mocked) Coverage.result" do
before do
@prev_filters = SimpleCov.filters
SimpleCov.filters = []
@prev_groups = SimpleCov.groups
SimpleCov.groups = {}
@prev_formatter = SimpleCov.formatter
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/command_guesser_spec.rb | Ruby | mit | 4,885 | main | 2,505 | # frozen_string_literal: true
require "helper"
describe SimpleCov::CommandGuesser do
subject { SimpleCov::CommandGuesser }
it 'correctly guesses "Unit Tests" for unit tests' do
subject.original_run_command = "/some/path/test/units/foo_bar_test.rb"
expect(subject.guess).to eq("Unit Tests")
subject.ori... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/filters_spec.rb | Ruby | mit | 4,885 | main | 8,371 | # frozen_string_literal: true
require "helper"
describe SimpleCov::SourceFile do
subject do
SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
end
it "doesn't match a new SimpleCov::StringFilter 'foobar'" do
expect(SimpleCov::StringFilter.new("foobar")).not... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/configuration_spec.rb | Ruby | mit | 4,885 | main | 11,788 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Configuration do
let(:config_class) do
Class.new do
include SimpleCov::Configuration
end
end
let(:config) { config_class.new }
describe "#print_error_status" do
subject { config.print_error_status }
context "when not ma... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/result_adapter_spec.rb | Ruby | mit | 4,885 | main | 2,303 | # frozen_string_literal: true
require "helper"
require "coverage"
describe SimpleCov::ResultAdapter do
subject { described_class.call(result_set) }
let(:existing_file) { source_fixture("app/models/user.rb") }
describe "with oneshot_lines coverage" do
before do
skip "oneshot_lines coverage not suppor... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/config_loader_spec.rb | Ruby | mit | 4,885 | main | 338 | # frozen_string_literal: true
require "helper"
describe "loading config" do
context "without ENV[HOME]" do
it "does not raise any errors" do
home = ENV.delete("HOME")
begin
expect { load "simplecov/load_global_config.rb" }.not_to raise_error
ensure
ENV["HOME"] = home
end
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/multi_formatter_spec.rb | Ruby | mit | 4,885 | main | 601 | # frozen_string_literal: true
require "helper"
require "simplecov/formatter/multi_formatter"
describe SimpleCov::Formatter::MultiFormatter do
describe ".[]" do
# Regression test for https://github.com/simplecov-ruby/simplecov/issues/428
it "constructs a formatter with multiple children" do
# Silence ... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/lines_classifier_spec.rb | Ruby | mit | 4,885 | main | 3,155 | # frozen_string_literal: true
require "helper"
require "simplecov/lines_classifier"
describe SimpleCov::LinesClassifier do
describe "#classify" do
describe "relevant lines" do
it "determines code as relevant" do
classified_lines = subject.classify [
"module Foo",
" class Baz",... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/simplecov_spec.rb | Ruby | mit | 4,885 | main | 10,809 | # frozen_string_literal: true
require "helper"
require "coverage"
describe SimpleCov do
describe ".result" do
before do
SimpleCov.clear_result
allow(Coverage).to receive(:result).once.and_return({})
end
context "with merging disabled" do
before do
allow(SimpleCov).to receive(:... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/return_codes_spec.rb | Ruby | mit | 4,885 | main | 2,169 | # frozen_string_literal: true
require "helper"
# Make sure that exit codes of tests are propagated properly
# See https://github.com/simplecov-ruby/simplecov/issues/5
describe "return codes" do
context "inside fixtures/frameworks" do
around do |test|
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures",... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/default_formatter_spec.rb | Ruby | mit | 4,885 | main | 1,061 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Formatter do
describe ".from_env" do
let(:env) { {"CC_TEST_REPORTER_ID" => "4c9f1de6193f30799e9a5d5c082692abecc1fd2c6aa62c621af7b2a910761970"} }
context "when CC_TEST_REPORTER_ID environment variable is set" do
it "returns an array co... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/deleted_source_spec.rb | Ruby | mit | 4,885 | main | 410 | # frozen_string_literal: true
require "helper"
# Test to verify correct handling of deleted files
# See https://github.com/simplecov-ruby/simplecov/issues/9
describe "A source file which is subsequently deleted" do
it "does not cause an error" do
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures")) do
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/coverage_for_eval_spec.rb | Ruby | mit | 4,885 | main | 597 | # frozen_string_literal: true
require "helper"
RSpec.describe "coverage for eval" do
if SimpleCov.coverage_for_eval_supported?
around do |test|
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "eval_test")) do
FileUtils.rm_rf("./coverage")
test.call
end
end
before do
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/defaults_spec.rb | Ruby | mit | 4,885 | main | 1,202 | # frozen_string_literal: true
require "helper"
describe SimpleCov do
skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]
context "profiles" do
let(:config_class) do
Class.new do
include SimpleCov::Configuration
def load_profile(name)
configure(&SimpleCov... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/json_formatter_spec.rb | Ruby | mit | 4,885 | main | 10,404 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Formatter::JSONFormatter do
subject { described_class.new(silent: true) }
let(:result) do
SimpleCov::Result.new({
source_fixture("json/sample.rb") => {"lines" => [
nil, 1, 1, 1, 1, nil... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/gemspec_spec.rb | Ruby | mit | 4,885 | main | 413 | # frozen_string_literal: true
require "open3"
RSpec.describe "gemspec sanity" do
after do
File.delete(Dir.glob("simplecov-*.gem").first)
end
let(:build) do
Bundler.with_original_env do
Open3.capture3("gem build simplecov.gemspec")
end
end
it "has no warnings" do
expect(build[1]).not_... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/combine/methods_combiner_spec.rb | Ruby | mit | 4,885 | main | 1,283 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Combine::MethodsCombiner do
describe ".combine" do
it "sums coverage for matching method keys" do
coverage_a = {
'["A", :method1, 2, 2, 5, 5]' => 3,
'["A", :method2, 9, 2, 11, 5]' => 0
}
coverage_b = {
'... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/combine/results_combiner_spec.rb | Ruby | mit | 4,885 | main | 6,583 | # frozen_string_literal: true
require "helper"
describe SimpleCov::Combine::ResultsCombiner do
describe "with two faked coverage resultsets" do
let(:resultset1) do
{
source_fixture("sample.rb") => {
"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
"branches" => {[:if, 3, 8,... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/exit_codes/minimum_overall_coverage_check_spec.rb | Ruby | mit | 4,885 | main | 974 | # frozen_string_literal: true
require "helper"
RSpec.describe SimpleCov::ExitCodes::MinimumOverallCoverageCheck do
subject { described_class.new(result, minimum_coverage) }
let(:result) do
instance_double(SimpleCov::Result, coverage_statistics: stats)
end
let(:stats) do
{
line: SimpleCov::Cover... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/exit_codes/maximum_coverage_drop_check_spec.rb | Ruby | mit | 4,885 | main | 2,321 | # frozen_string_literal: true
require "helper"
RSpec.describe SimpleCov::ExitCodes::MaximumCoverageDropCheck do
subject { described_class.new(result, maximum_coverage_drop) }
let(:result) do
instance_double(SimpleCov::Result, coverage_statistics: stats)
end
let(:stats) do
{
line: SimpleCov::Cov... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/exit_codes/minimum_coverage_by_file_check_spec.rb | Ruby | mit | 4,885 | main | 834 | # frozen_string_literal: true
require "helper"
RSpec.describe SimpleCov::ExitCodes::MinimumCoverageByFileCheck do
subject { described_class.new(result, minimum_coverage_by_file) }
let(:result) do
instance_double(SimpleCov::Result, files: files)
end
let(:coverage_statistics) { {line: SimpleCov::CoverageSt... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/exit_codes/minimum_coverage_by_group_check_spec.rb | Ruby | mit | 4,885 | main | 1,597 | # frozen_string_literal: true
require "helper"
RSpec.describe SimpleCov::ExitCodes::MinimumCoverageByGroupCheck do
subject { described_class.new(result, minimum_coverage_by_group) }
let(:coverage_statistics) { {line: SimpleCov::CoverageStatistics.new(covered: 8, missed: 2), branch: SimpleCov::CoverageStatistics.... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/source_file/method_spec.rb | Ruby | mit | 4,885 | main | 1,254 | # frozen_string_literal: true
require "helper"
describe SimpleCov::SourceFile::Method do
subject { described_class.new(source_file, info, coverage) }
let(:source_file) do
SimpleCov::SourceFile.new(source_fixture("methods.rb"), {"lines" => {}})
end
let(:info) { ["A", :method1, 2, 2, 5, 5] }
let(:covera... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/source_file/line_spec.rb | Ruby | mit | 4,885 | main | 3,491 | # frozen_string_literal: true
require "helper"
describe SimpleCov::SourceFile::Line do
context "a source line" do
subject do
SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
end
it 'returns "# the ruby source" as src' do
expect(subject.src).to eq("# the ruby source")
end
... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/source_file/branch_spec.rb | Ruby | mit | 4,885 | main | 2,948 | # frozen_string_literal: true
require "helper"
describe SimpleCov::SourceFile::Branch do
let(:if_branch) do
described_class.new(start_line: 1, end_line: 3, coverage: 0, inline: false, type: :then)
end
let(:else_branch) do
described_class.new(start_line: 1, end_line: 3, coverage: 0, inline: false, type:... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | spec/support/fail_rspec_on_ruby_warning.rb | Ruby | mit | 4,885 | main | 1,715 | # frozen_string_literal: true
# Borrowed and heavily adjusted from:
# https://github.com/metricfu/metric_fu/blob/master/spec/capture_warnings.rb
require "fileutils"
class FailOnWarnings
def initialize
@stderr_stream = StringIO.new
@app_root = Dir.pwd
end
def collect_warnings
$stderr = @stderr_strea... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/monorepo/Gemfile | Ruby | mit | 4,885 | main | 385 | source "https://rubygems.org"
gem "rspec"
gem "base", path: "base"
gem "extra", path: "extra"
# when the tests are executed the project is in tmp/aruba/project
# which is a different nesting from its usual place
root = File.expand_path("../..", __dir__)
unless File.exist?("#{root}/simplecov.gemspec")
root = File.e... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/monorepo/base/base.gemspec | Ruby | mit | 4,885 | main | 380 | # frozen_string_literal: true
Gem::Specification.new do |gem|
gem.name = "base"
gem.version = "0.0.1"
gem.authors = ["Someone"]
gem.email = ["someonesemail"]
gem.homepage = "https://example.org"
gem.summary = "Base stuff"
gem.description = %(Base stuff, really)
gem.license ... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/monorepo/extra/extra.gemspec | Ruby | mit | 4,885 | main | 412 | # frozen_string_literal: true
Gem::Specification.new do |gem|
gem.name = "extra"
gem.version = "0.0.1"
gem.authors = ["Someone"]
gem.email = ["someonesemail"]
gem.homepage = "https://example.org"
gem.summary = "Extra stuff"
gem.description = %(Extra stuff, really)
gem.licens... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/monorepo/extra/spec/extra_spec.rb | Ruby | mit | 4,885 | main | 256 | # frozen_string_literal: true
require "spec_helper"
require "monorepo/extra"
RSpec.describe Monorepo::Extra do
describe "#identity" do
it "returns the same string" do
expect(described_class.new("foo").identity).to eq("foo")
end
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/monorepo/extra/lib/monorepo/extra.rb | Ruby | mit | 4,885 | main | 226 | # frozen_string_literal: true
require "monorepo/base"
module Monorepo
class Extra
def initialize(label)
@label = label
end
def identity
Base.new(Base.new(@label).reverse).reverse
end
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/parallel_tests/Gemfile | Ruby | mit | 4,885 | main | 417 | # frozen_string_literal: true
source "https://rubygems.org"
gem "parallel_tests"
gem "rspec"
# when the tests are executed the project is in tmp/aruba/project
# which is a different nesting from its usual place
if File.exist?("../../simplecov.gemspec")
gem "simplecov", path: "../.."
else
# rubocop:disable Bundle... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/parallel_tests/spec/d_spec.rb | Ruby | mit | 4,885 | main | 202 | # frozen_string_literal: true
require "spec_helper"
describe D do
it "case 4" do
expect(subject.case(4)).to eq :foo
end
it "case nil" do
expect(subject.case(nil)).to eq :nope
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/parallel_tests/spec/spec_helper.rb | Ruby | mit | 4,885 | main | 296 | # frozen_string_literal: true
# We're injecting simplecov_config via aruba in cucumber here
# depending on what the test case is...
begin
require File.join(File.dirname(__FILE__), "simplecov_config")
rescue LoadError
warn "No SimpleCov config file found!"
end
require_relative "../lib/all" |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/encodings/lib/euc_jp_not_declared_tracked.rb | Ruby | mit | 4,885 | main | 223 | # frozen_string_literal: true
# Ruby can't even execute this file but it might be added
# via track_files or similar means and we still don't wanna crash!
class NoDeclare
MSG = "¤ª¤Ï¤è¤¦"
def ??
"tada!"
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/encodings/spec/spec_helper.rb | Ruby | mit | 4,885 | main | 246 | # frozen_string_literal: true
require "simplecov"
SimpleCov.start do
track_files "lib/euc_jp_not_declared_tracked.rb"
end
require_relative "../lib/utf8.rb"
require_relative "../lib/euc_jp.rb"
require_relative "../lib/euc_jp_not_declared.rb" |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/faked_project/Rakefile | Ruby | mit | 4,885 | main | 751 | # frozen_string_literal: true
require "bundler"
require "rake/testtask"
Rake::TestTask.new(:test) do |test|
test.libs << "lib" << "test"
test.test_files = FileList["test/**/*_test.rb"].sort
test.verbose = true
end
Rake::TestTask.new(:part1) do |test|
test.libs << "lib"
test.test_files = FileList["test/**/*... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/faked_project/spec/forking_spec.rb | Ruby | mit | 4,885 | main | 264 | # frozen_string_literal: true
require "spec_helper"
describe "forking" do
it do
# TODO: The defined?(RUBY_ENGINE) check can be dropped for simplecov 1.0.0
Process.waitpid(Kernel.fork {}) unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/faked_project/spec/some_class_spec.rb | Ruby | mit | 4,885 | main | 288 | # frozen_string_literal: true
require "spec_helper"
describe SomeClass do
subject { SomeClass.new("foo") }
it "should be reversible" do
expect(subject.reverse).to eq("oof")
end
it "should compare with 'foo'" do
expect(subject.compare_with("foo")).to be true
end
end |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/faked_project/spec/spec_helper.rb | Ruby | mit | 4,885 | main | 315 | # frozen_string_literal: true
require "bundler/setup"
# We're injecting simplecov_config via aruba in cucumber here
# depending on what the test case is...
begin
require File.join(File.dirname(__FILE__), "simplecov_config")
rescue LoadError
warn "No SimpleCov config file found!"
end
require "faked_project" |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/faked_project/spec/meta_magic_spec.rb | Ruby | mit | 4,885 | main | 554 | # frozen_string_literal: true
require "spec_helper"
describe FakedProject do
it "should have added a class method to FakedProject" do
expect(FakedProject.a_class_method).to eq("this is a mixed-in class method")
end
it "should have added a mixed-in instance method to FakedProject" do
expect(subject.an_i... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | test_projects/faked_project/spec/faked_spec.rb | Ruby | mit | 4,885 | main | 292 | # frozen_string_literal: true
require "spec_helper"
describe FakedProject do
it "should return proper foo" do
expect(FakedProject.foo).to eq("bar")
end
it "should test it's framework specific method" do
expect(FrameworkSpecific.rspec).to eq("Only tested in RSpec")
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.