simplecov 0.15.1 → 0.18.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -1
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +12 -9
- data/ISSUE_TEMPLATE.md +23 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +300 -115
- data/doc/alternate-formatters.md +20 -0
- data/lib/simplecov.rb +298 -45
- data/lib/simplecov/combine.rb +30 -0
- data/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/lib/simplecov/combine/files_combiner.rb +24 -0
- data/lib/simplecov/combine/lines_combiner.rb +43 -0
- data/lib/simplecov/combine/results_combiner.rb +100 -0
- data/lib/simplecov/command_guesser.rb +8 -3
- data/lib/simplecov/configuration.rb +95 -8
- data/lib/simplecov/defaults.rb +13 -80
- data/lib/simplecov/exit_codes.rb +2 -0
- data/lib/simplecov/file_list.rb +32 -3
- data/lib/simplecov/filter.rb +5 -2
- data/lib/simplecov/formatter.rb +2 -0
- data/lib/simplecov/formatter/multi_formatter.rb +4 -2
- data/lib/simplecov/formatter/simple_formatter.rb +6 -4
- data/lib/simplecov/last_run.rb +5 -1
- data/lib/simplecov/lines_classifier.rb +21 -5
- data/lib/simplecov/load_global_config.rb +2 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles.rb +11 -7
- data/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +18 -0
- data/lib/simplecov/profiles/root_filter.rb +10 -0
- data/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/lib/simplecov/result.rb +13 -4
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +20 -11
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file.rb +190 -109
- data/lib/simplecov/source_file/branch.rb +84 -0
- data/lib/simplecov/source_file/line.rb +72 -0
- data/lib/simplecov/useless_results_remover.rb +16 -0
- data/lib/simplecov/version.rb +3 -1
- metadata +44 -162
- data/.gitignore +0 -31
- data/.rspec +0 -3
- data/.rubocop.yml +0 -88
- data/.travis.yml +0 -29
- data/.yardopts +0 -1
- data/Gemfile +0 -38
- data/Rakefile +0 -39
- data/cucumber.yml +0 -13
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -45
- data/features/config_coverage_dir.feature +0 -33
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_formatters.feature +0 -77
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_profiles.feature +0 -44
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -121
- data/features/config_tracked_files.feature +0 -29
- data/features/config_tracked_files_relevant_lines.feature +0 -31
- data/features/cucumber_basic.feature +0 -29
- data/features/maximum_coverage_drop.feature +0 -89
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/minimum_coverage.feature +0 -59
- data/features/refuse_coverage_drop.feature +0 -95
- data/features/rspec_basic.feature +0 -32
- data/features/rspec_fails_on_initialization.feature +0 -14
- data/features/rspec_groups_and_filters_basic.feature +0 -29
- data/features/rspec_groups_and_filters_complex.feature +0 -37
- data/features/rspec_groups_using_filter_class.feature +0 -41
- data/features/rspec_without_simplecov.feature +0 -20
- data/features/skipping_code_blocks_manually.feature +0 -70
- data/features/step_definitions/html_steps.rb +0 -44
- data/features/step_definitions/simplecov_steps.rb +0 -68
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/aruba_freedom_patch.rb +0 -53
- data/features/support/env.rb +0 -50
- data/features/test_unit_basic.feature +0 -34
- data/features/test_unit_groups_and_filters_basic.feature +0 -29
- data/features/test_unit_groups_and_filters_complex.feature +0 -35
- data/features/test_unit_groups_using_filter_class.feature +0 -40
- data/features/test_unit_without_simplecov.feature +0 -20
- data/features/unicode_compatiblity.feature +0 -67
- data/lib/simplecov/jruby_fix.rb +0 -42
- data/lib/simplecov/railtie.rb +0 -7
- data/lib/simplecov/railties/tasks.rake +0 -11
- data/lib/simplecov/raw_coverage.rb +0 -39
- data/simplecov.gemspec +0 -27
- data/spec/1_8_fallbacks_spec.rb +0 -31
- data/spec/command_guesser_spec.rb +0 -48
- data/spec/config_loader_spec.rb +0 -14
- data/spec/configuration_spec.rb +0 -35
- data/spec/defaults_spec.rb +0 -41
- data/spec/deleted_source_spec.rb +0 -12
- data/spec/faked_project/Gemfile +0 -6
- data/spec/faked_project/Rakefile +0 -8
- data/spec/faked_project/cucumber.yml +0 -13
- data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
- data/spec/faked_project/features/support/env.rb +0 -12
- data/spec/faked_project/features/test_stuff.feature +0 -6
- data/spec/faked_project/lib/faked_project.rb +0 -11
- data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
- data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
- data/spec/faked_project/spec/faked_spec.rb +0 -11
- data/spec/faked_project/spec/forking_spec.rb +0 -8
- data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
- data/spec/faked_project/spec/some_class_spec.rb +0 -13
- data/spec/faked_project/spec/spec_helper.rb +0 -11
- data/spec/faked_project/test/faked_test.rb +0 -11
- data/spec/faked_project/test/meta_magic_test.rb +0 -13
- data/spec/faked_project/test/some_class_test.rb +0 -15
- data/spec/faked_project/test/test_helper.rb +0 -12
- data/spec/file_list_spec.rb +0 -50
- data/spec/filters_spec.rb +0 -202
- data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
- data/spec/fixtures/app/models/user.rb +0 -10
- data/spec/fixtures/deleted_source_sample.rb +0 -15
- data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
- data/spec/fixtures/frameworks/rspec_good.rb +0 -9
- data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
- data/spec/fixtures/frameworks/testunit_good.rb +0 -9
- data/spec/fixtures/iso-8859.rb +0 -3
- data/spec/fixtures/never.rb +0 -2
- data/spec/fixtures/resultset1.rb +0 -4
- data/spec/fixtures/resultset2.rb +0 -4
- data/spec/fixtures/sample.rb +0 -16
- data/spec/fixtures/skipped.rb +0 -4
- data/spec/fixtures/skipped_and_executed.rb +0 -8
- data/spec/fixtures/utf-8.rb +0 -3
- data/spec/helper.rb +0 -26
- data/spec/last_run_spec.rb +0 -48
- data/spec/lines_classifier_spec.rb +0 -103
- data/spec/multi_formatter_spec.rb +0 -20
- data/spec/raw_coverage_spec.rb +0 -92
- data/spec/result_merger_spec.rb +0 -171
- data/spec/result_spec.rb +0 -209
- data/spec/return_codes_spec.rb +0 -34
- data/spec/simplecov_spec.rb +0 -109
- data/spec/source_file_line_spec.rb +0 -155
- data/spec/source_file_spec.rb +0 -145
- data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
@@ -1,12 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
|
3
|
-
# We're injecting simplecov_config via aruba in cucumber here
|
4
|
-
# depending on what the test case is...
|
5
|
-
begin
|
6
|
-
require File.join(File.dirname(__FILE__), "simplecov_config")
|
7
|
-
rescue LoadError
|
8
|
-
$stderr.puts "No SimpleCov config file found!"
|
9
|
-
end
|
10
|
-
|
11
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/../../lib"))
|
12
|
-
require "faked_project"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class FakedProject
|
2
|
-
def self.foo
|
3
|
-
"bar"
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
Dir[File.join(File.dirname(__FILE__), "faked_project/*.rb")].reject { |f| /untested/.match(f) }.each do |file|
|
8
|
-
require file # Require all source files in project dynamically so we can inject some stuff depending on test situation
|
9
|
-
end
|
10
|
-
|
11
|
-
FakedProject.send :include, MetaMagic
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# A pile of methods that only get tested in their frameworks
|
2
|
-
# and thus make this file only 100% covered when all framework test
|
3
|
-
# results are merged
|
4
|
-
module FrameworkSpecific
|
5
|
-
class << self
|
6
|
-
def cucumber
|
7
|
-
"Only tested in Cucumber"
|
8
|
-
end
|
9
|
-
|
10
|
-
def rspec
|
11
|
-
"Only tested in RSpec"
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_unit
|
15
|
-
"Only tested in Test/Unit"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module MetaMagic
|
2
|
-
module ClassMethods
|
3
|
-
def a_class_method
|
4
|
-
"this is a mixed-in class method"
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
module InstanceMethods
|
9
|
-
def an_instance_method
|
10
|
-
"this is a mixed-in instance method"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.included(base)
|
15
|
-
base.send :extend, ClassMethods
|
16
|
-
base.send :include, InstanceMethods
|
17
|
-
|
18
|
-
base.class_eval do
|
19
|
-
define_method :dynamic do
|
20
|
-
"A dynamically defined instance method"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class SomeClass
|
2
|
-
attr_reader :label
|
3
|
-
attr_accessor :some_attr
|
4
|
-
|
5
|
-
def initialize(label)
|
6
|
-
@label = label
|
7
|
-
end
|
8
|
-
|
9
|
-
def reverse
|
10
|
-
label.reverse
|
11
|
-
end
|
12
|
-
|
13
|
-
def compare_with(item)
|
14
|
-
if item == label
|
15
|
-
return true
|
16
|
-
else
|
17
|
-
raise "Item does not match label"
|
18
|
-
end
|
19
|
-
rescue
|
20
|
-
false
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def uncovered
|
26
|
-
"private method"
|
27
|
-
end
|
28
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe FakedProject do
|
4
|
-
it "should return proper foo" do
|
5
|
-
expect(FakedProject.foo).to eq("bar")
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should test it's framework specific method" do
|
9
|
-
expect(FrameworkSpecific.rspec).to eq("Only tested in RSpec")
|
10
|
-
end
|
11
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe FakedProject do
|
4
|
-
it "should have added a class method to FakedProject" do
|
5
|
-
expect(FakedProject.a_class_method).to eq("this is a mixed-in class method")
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should have added a mixed-in instance method to FakedProject" do
|
9
|
-
expect(subject.an_instance_method).to eq("this is a mixed-in instance method")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should have added a dyntamically-defined instance method to FakedProject" do
|
13
|
-
expect(subject.dynamic).to eq("A dynamically defined instance method")
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SomeClass do
|
4
|
-
subject { SomeClass.new("foo") }
|
5
|
-
|
6
|
-
it "should be reversible" do
|
7
|
-
expect(subject.reverse).to eq("oof")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should compare with 'foo'" do
|
11
|
-
expect(subject.compare_with("foo")).to be true
|
12
|
-
end
|
13
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
|
3
|
-
# We're injecting simplecov_config via aruba in cucumber here
|
4
|
-
# depending on what the test case is...
|
5
|
-
begin
|
6
|
-
require File.join(File.dirname(__FILE__), "simplecov_config")
|
7
|
-
rescue LoadError
|
8
|
-
$stderr.puts "No SimpleCov config file found!"
|
9
|
-
end
|
10
|
-
|
11
|
-
require "faked_project"
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class MetaMagicTest < Test::Unit::TestCase
|
4
|
-
def test_class_methods
|
5
|
-
assert_equal "this is a mixed-in class method", FakedProject.a_class_method
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_instance_methods
|
9
|
-
p = FakedProject.new
|
10
|
-
assert_equal "this is a mixed-in instance method", p.an_instance_method
|
11
|
-
assert_equal "A dynamically defined instance method", p.dynamic
|
12
|
-
end
|
13
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class SomeClassTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@instance = SomeClass.new("foo")
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_reverse
|
9
|
-
assert_equal "oof", @instance.reverse
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_comparison
|
13
|
-
assert @instance.compare_with("foo")
|
14
|
-
end
|
15
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
|
3
|
-
# We're injecting simplecov_config via aruba in cucumber here
|
4
|
-
# depending on what the test case is...
|
5
|
-
begin
|
6
|
-
require File.join(File.dirname(__FILE__), "simplecov_config")
|
7
|
-
rescue LoadError
|
8
|
-
$stderr.puts "No SimpleCov config file found!"
|
9
|
-
end
|
10
|
-
|
11
|
-
require "faked_project"
|
12
|
-
require "test/unit"
|
data/spec/file_list_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
if SimpleCov.usable?
|
4
|
-
describe SimpleCov::Result do
|
5
|
-
subject do
|
6
|
-
original_result = {
|
7
|
-
source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
8
|
-
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
9
|
-
source_fixture("app/controllers/sample_controller.rb") => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil],
|
10
|
-
}
|
11
|
-
SimpleCov::Result.new(original_result).files
|
12
|
-
end
|
13
|
-
|
14
|
-
it "has 11 covered lines" do
|
15
|
-
expect(subject.covered_lines).to eq(11)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "has 3 missed lines" do
|
19
|
-
expect(subject.missed_lines).to eq(3)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "has 17 never lines" do
|
23
|
-
expect(subject.never_lines).to eq(17)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "has 14 lines of code" do
|
27
|
-
expect(subject.lines_of_code).to eq(14)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "has 5 skipped lines" do
|
31
|
-
expect(subject.skipped_lines).to eq(5)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "has the correct covered percent" do
|
35
|
-
expect(subject.covered_percent).to eq(78.57142857142857)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "has the correct covered percentages" do
|
39
|
-
expect(subject.covered_percentages).to eq([50.0, 80.0, 100.0])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "has the correct least covered file" do
|
43
|
-
expect(subject.least_covered_file).to match(/sample_controller.rb/)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "has the correct covered strength" do
|
47
|
-
expect(subject.covered_strength).to eq(0.9285714285714286)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/spec/filters_spec.rb
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
if SimpleCov.usable?
|
4
|
-
describe SimpleCov::SourceFile do
|
5
|
-
subject do
|
6
|
-
SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "doesn't match a new SimpleCov::StringFilter 'foobar'" do
|
10
|
-
expect(SimpleCov::StringFilter.new("foobar")).not_to be_matches subject
|
11
|
-
end
|
12
|
-
|
13
|
-
it "doesn't match a new SimpleCov::StringFilter 'some/path'" do
|
14
|
-
expect(SimpleCov::StringFilter.new("some/path")).not_to be_matches subject
|
15
|
-
end
|
16
|
-
|
17
|
-
it "matches a new SimpleCov::StringFilter 'spec/fixtures'" do
|
18
|
-
expect(SimpleCov::StringFilter.new("spec/fixtures")).to be_matches subject
|
19
|
-
end
|
20
|
-
|
21
|
-
it "matches a new SimpleCov::StringFilter 'spec/fixtures/sample.rb'" do
|
22
|
-
expect(SimpleCov::StringFilter.new("spec/fixtures/sample.rb")).to be_matches subject
|
23
|
-
end
|
24
|
-
|
25
|
-
it "matches a new SimpleCov::StringFilter 'sample.rb'" do
|
26
|
-
expect(SimpleCov::StringFilter.new("sample.rb")).to be_matches subject
|
27
|
-
end
|
28
|
-
|
29
|
-
it "doesn't match a parent directory with a new SimpleCov::StringFilter" do
|
30
|
-
parent_dir_name = File.basename(File.expand_path("..", File.dirname(__FILE__)))
|
31
|
-
expect(SimpleCov::StringFilter.new(parent_dir_name)).not_to be_matches subject
|
32
|
-
end
|
33
|
-
|
34
|
-
it "matches a new SimpleCov::StringFilter '/fixtures/'" do
|
35
|
-
expect(SimpleCov::StringFilter.new("sample.rb")).to be_matches subject
|
36
|
-
end
|
37
|
-
|
38
|
-
it "matches a new SimpleCov::RegexFilter /\/fixtures\//" do
|
39
|
-
expect(SimpleCov::RegexFilter.new(/\/fixtures\//)).to be_matches subject
|
40
|
-
end
|
41
|
-
|
42
|
-
it "doesn't match a new SimpleCov::RegexFilter /^\/fixtures\//" do
|
43
|
-
expect(SimpleCov::RegexFilter.new(/^\/fixtures\//)).not_to be_matches subject
|
44
|
-
end
|
45
|
-
|
46
|
-
it "matches a new SimpleCov::RegexFilter /^\/spec\//" do
|
47
|
-
expect(SimpleCov::RegexFilter.new(/^\/spec\//)).to be_matches subject
|
48
|
-
end
|
49
|
-
|
50
|
-
it "doesn't match a new SimpleCov::BlockFilter that is not applicable" do
|
51
|
-
expect(SimpleCov::BlockFilter.new(proc { |s| File.basename(s.filename) == "foo.rb" })).not_to be_matches subject
|
52
|
-
end
|
53
|
-
|
54
|
-
it "matches a new SimpleCov::BlockFilter that is applicable" do
|
55
|
-
expect(SimpleCov::BlockFilter.new(proc { |s| File.basename(s.filename) == "sample.rb" })).to be_matches subject
|
56
|
-
end
|
57
|
-
|
58
|
-
it "matches a new SimpleCov::ArrayFilter when 'sample.rb' is passed as array" do
|
59
|
-
expect(SimpleCov::ArrayFilter.new(["sample.rb"])).to be_matches subject
|
60
|
-
end
|
61
|
-
|
62
|
-
it "doesn't match a new SimpleCov::ArrayFilter when a file path different than 'sample.rb' is passed as array" do
|
63
|
-
expect(SimpleCov::ArrayFilter.new(["other_file.rb"])).not_to be_matches subject
|
64
|
-
end
|
65
|
-
|
66
|
-
it "matches a new SimpleCov::ArrayFilter when two file paths including 'sample.rb' are passed as array" do
|
67
|
-
expect(SimpleCov::ArrayFilter.new(["sample.rb", "other_file.rb"])).to be_matches subject
|
68
|
-
end
|
69
|
-
|
70
|
-
it "doesn't match a parent directory with a new SimpleCov::ArrayFilter" do
|
71
|
-
parent_dir_name = File.basename(File.expand_path("..", File.dirname(__FILE__)))
|
72
|
-
expect(SimpleCov::ArrayFilter.new([parent_dir_name])).not_to be_matches subject
|
73
|
-
end
|
74
|
-
|
75
|
-
it "matches a new SimpleCov::ArrayFilter when /sample.rb/ is passed as array" do
|
76
|
-
expect(SimpleCov::ArrayFilter.new([/sample.rb/])).to be_matches subject
|
77
|
-
end
|
78
|
-
|
79
|
-
it "doesn't match a new SimpleCov::ArrayFilter when a file path different than /sample.rb/ is passed as array" do
|
80
|
-
expect(SimpleCov::ArrayFilter.new([/other_file.rb/])).not_to be_matches subject
|
81
|
-
end
|
82
|
-
|
83
|
-
it "matches a new SimpleCov::ArrayFilter when a block is passed as array and returns true" do
|
84
|
-
expect(SimpleCov::ArrayFilter.new([proc { true }])).to be_matches subject
|
85
|
-
end
|
86
|
-
|
87
|
-
it "doesn't match a new SimpleCov::ArrayFilter when a block that returns false is passed as array" do
|
88
|
-
expect(SimpleCov::ArrayFilter.new([proc { false }])).not_to be_matches subject
|
89
|
-
end
|
90
|
-
|
91
|
-
it "matches a new SimpleCov::ArrayFilter when a custom class that returns true is passed as array" do
|
92
|
-
filter = Class.new(SimpleCov::Filter) do
|
93
|
-
def matches?(_)
|
94
|
-
true
|
95
|
-
end
|
96
|
-
end.new(nil)
|
97
|
-
expect(SimpleCov::ArrayFilter.new([filter])).to be_matches subject
|
98
|
-
end
|
99
|
-
|
100
|
-
it "doesn't match a new SimpleCov::ArrayFilter when a custom class that returns false is passed as array" do
|
101
|
-
filter = Class.new(SimpleCov::Filter) do
|
102
|
-
def matches?(_)
|
103
|
-
false
|
104
|
-
end
|
105
|
-
end.new(nil)
|
106
|
-
expect(SimpleCov::ArrayFilter.new([filter])).not_to be_matches subject
|
107
|
-
end
|
108
|
-
|
109
|
-
context "with no filters set up and a basic source file in an array" do
|
110
|
-
before do
|
111
|
-
@prev_filters = SimpleCov.filters
|
112
|
-
SimpleCov.filters = []
|
113
|
-
end
|
114
|
-
|
115
|
-
subject do
|
116
|
-
[SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])]
|
117
|
-
end
|
118
|
-
|
119
|
-
after do
|
120
|
-
SimpleCov.filters = @prev_filters
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'returns 0 items after executing SimpleCov.filtered on files when using a "sample" string filter' do
|
124
|
-
SimpleCov.add_filter "sample"
|
125
|
-
expect(SimpleCov.filtered(subject).count).to be_zero
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'returns 0 items after executing SimpleCov.filtered on files when using a "spec/fixtures" string filter' do
|
129
|
-
SimpleCov.add_filter "spec/fixtures"
|
130
|
-
expect(SimpleCov.filtered(subject).count).to be_zero
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'returns 1 item after executing SimpleCov.filtered on files when using a "fooo" string filter' do
|
134
|
-
SimpleCov.add_filter "fooo"
|
135
|
-
expect(SimpleCov.filtered(subject).count).to eq(1)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "returns 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do
|
139
|
-
SimpleCov.add_filter do
|
140
|
-
true
|
141
|
-
end
|
142
|
-
expect(SimpleCov.filtered(subject).count).to be_zero
|
143
|
-
end
|
144
|
-
|
145
|
-
it "returns 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do
|
146
|
-
SimpleCov.add_filter do
|
147
|
-
false
|
148
|
-
end
|
149
|
-
expect(SimpleCov.filtered(subject).count).to eq(1)
|
150
|
-
end
|
151
|
-
|
152
|
-
it "returns a FileList after filtering" do
|
153
|
-
SimpleCov.add_filter "fooo"
|
154
|
-
expect(SimpleCov.filtered(subject)).to be_a SimpleCov::FileList
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
context "with the default configuration" do
|
159
|
-
skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]
|
160
|
-
|
161
|
-
def a_file(path)
|
162
|
-
path = File.join(SimpleCov.root, path) unless path.start_with?("/")
|
163
|
-
SimpleCov::SourceFile.new(path, [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
|
164
|
-
end
|
165
|
-
|
166
|
-
context "inside the project" do
|
167
|
-
it "doesn't filter" do
|
168
|
-
expect(SimpleCov.filtered([a_file("foo.rb")]).count).to eq(1)
|
169
|
-
end
|
170
|
-
|
171
|
-
it "filters vendor/bundle" do
|
172
|
-
expect(SimpleCov.filtered([a_file("vendor/bundle/foo.rb")]).count).to eq(0)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
context "outside the project" do
|
177
|
-
it "filters" do
|
178
|
-
expect(SimpleCov.filtered([a_file("/other/path/foo.rb")]).count).to eq(0)
|
179
|
-
end
|
180
|
-
|
181
|
-
it "filters even if the sibling directory has SimpleCov.root as a prefix" do
|
182
|
-
sibling_dir = SimpleCov.root + "_cache"
|
183
|
-
expect(SimpleCov.filtered([a_file(sibling_dir + "/foo.rb")]).count).to eq(0)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe ".class_for_argument" do
|
189
|
-
it "returns SimpleCov::StringFilter for a string" do
|
190
|
-
expect(SimpleCov::Filter.class_for_argument("filestring")).to eq(SimpleCov::StringFilter)
|
191
|
-
end
|
192
|
-
|
193
|
-
it "returns SimpleCov::RegexFilter for a string" do
|
194
|
-
expect(SimpleCov::Filter.class_for_argument(/regex/)).to eq(SimpleCov::RegexFilter)
|
195
|
-
end
|
196
|
-
|
197
|
-
it "returns SimpleCov::RegexFilter for a string" do
|
198
|
-
expect(SimpleCov::Filter.class_for_argument(%w[file1 file2])).to eq(SimpleCov::ArrayFilter)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|