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.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -1
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +12 -9
  5. data/ISSUE_TEMPLATE.md +23 -0
  6. data/{MIT-LICENSE → LICENSE} +0 -0
  7. data/README.md +300 -115
  8. data/doc/alternate-formatters.md +20 -0
  9. data/lib/simplecov.rb +298 -45
  10. data/lib/simplecov/combine.rb +30 -0
  11. data/lib/simplecov/combine/branches_combiner.rb +32 -0
  12. data/lib/simplecov/combine/files_combiner.rb +24 -0
  13. data/lib/simplecov/combine/lines_combiner.rb +43 -0
  14. data/lib/simplecov/combine/results_combiner.rb +100 -0
  15. data/lib/simplecov/command_guesser.rb +8 -3
  16. data/lib/simplecov/configuration.rb +95 -8
  17. data/lib/simplecov/defaults.rb +13 -80
  18. data/lib/simplecov/exit_codes.rb +2 -0
  19. data/lib/simplecov/file_list.rb +32 -3
  20. data/lib/simplecov/filter.rb +5 -2
  21. data/lib/simplecov/formatter.rb +2 -0
  22. data/lib/simplecov/formatter/multi_formatter.rb +4 -2
  23. data/lib/simplecov/formatter/simple_formatter.rb +6 -4
  24. data/lib/simplecov/last_run.rb +5 -1
  25. data/lib/simplecov/lines_classifier.rb +21 -5
  26. data/lib/simplecov/load_global_config.rb +2 -0
  27. data/lib/simplecov/no_defaults.rb +2 -0
  28. data/lib/simplecov/profiles.rb +11 -7
  29. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  30. data/lib/simplecov/profiles/hidden_filter.rb +5 -0
  31. data/lib/simplecov/profiles/rails.rb +18 -0
  32. data/lib/simplecov/profiles/root_filter.rb +10 -0
  33. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  34. data/lib/simplecov/result.rb +13 -4
  35. data/lib/simplecov/result_adapter.rb +30 -0
  36. data/lib/simplecov/result_merger.rb +20 -11
  37. data/lib/simplecov/simulate_coverage.rb +29 -0
  38. data/lib/simplecov/source_file.rb +190 -109
  39. data/lib/simplecov/source_file/branch.rb +84 -0
  40. data/lib/simplecov/source_file/line.rb +72 -0
  41. data/lib/simplecov/useless_results_remover.rb +16 -0
  42. data/lib/simplecov/version.rb +3 -1
  43. metadata +44 -162
  44. data/.gitignore +0 -31
  45. data/.rspec +0 -3
  46. data/.rubocop.yml +0 -88
  47. data/.travis.yml +0 -29
  48. data/.yardopts +0 -1
  49. data/Gemfile +0 -38
  50. data/Rakefile +0 -39
  51. data/cucumber.yml +0 -13
  52. data/features/config_autoload.feature +0 -46
  53. data/features/config_command_name.feature +0 -45
  54. data/features/config_coverage_dir.feature +0 -33
  55. data/features/config_deactivate_merging.feature +0 -42
  56. data/features/config_formatters.feature +0 -77
  57. data/features/config_merge_timeout.feature +0 -39
  58. data/features/config_nocov_token.feature +0 -79
  59. data/features/config_profiles.feature +0 -44
  60. data/features/config_project_name.feature +0 -27
  61. data/features/config_styles.feature +0 -121
  62. data/features/config_tracked_files.feature +0 -29
  63. data/features/config_tracked_files_relevant_lines.feature +0 -31
  64. data/features/cucumber_basic.feature +0 -29
  65. data/features/maximum_coverage_drop.feature +0 -89
  66. data/features/merging_test_unit_and_rspec.feature +0 -44
  67. data/features/minimum_coverage.feature +0 -59
  68. data/features/refuse_coverage_drop.feature +0 -95
  69. data/features/rspec_basic.feature +0 -32
  70. data/features/rspec_fails_on_initialization.feature +0 -14
  71. data/features/rspec_groups_and_filters_basic.feature +0 -29
  72. data/features/rspec_groups_and_filters_complex.feature +0 -37
  73. data/features/rspec_groups_using_filter_class.feature +0 -41
  74. data/features/rspec_without_simplecov.feature +0 -20
  75. data/features/skipping_code_blocks_manually.feature +0 -70
  76. data/features/step_definitions/html_steps.rb +0 -44
  77. data/features/step_definitions/simplecov_steps.rb +0 -68
  78. data/features/step_definitions/transformers.rb +0 -13
  79. data/features/step_definitions/web_steps.rb +0 -64
  80. data/features/support/aruba_freedom_patch.rb +0 -53
  81. data/features/support/env.rb +0 -50
  82. data/features/test_unit_basic.feature +0 -34
  83. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  84. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  85. data/features/test_unit_groups_using_filter_class.feature +0 -40
  86. data/features/test_unit_without_simplecov.feature +0 -20
  87. data/features/unicode_compatiblity.feature +0 -67
  88. data/lib/simplecov/jruby_fix.rb +0 -42
  89. data/lib/simplecov/railtie.rb +0 -7
  90. data/lib/simplecov/railties/tasks.rake +0 -11
  91. data/lib/simplecov/raw_coverage.rb +0 -39
  92. data/simplecov.gemspec +0 -27
  93. data/spec/1_8_fallbacks_spec.rb +0 -31
  94. data/spec/command_guesser_spec.rb +0 -48
  95. data/spec/config_loader_spec.rb +0 -14
  96. data/spec/configuration_spec.rb +0 -35
  97. data/spec/defaults_spec.rb +0 -41
  98. data/spec/deleted_source_spec.rb +0 -12
  99. data/spec/faked_project/Gemfile +0 -6
  100. data/spec/faked_project/Rakefile +0 -8
  101. data/spec/faked_project/cucumber.yml +0 -13
  102. data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
  103. data/spec/faked_project/features/support/env.rb +0 -12
  104. data/spec/faked_project/features/test_stuff.feature +0 -6
  105. data/spec/faked_project/lib/faked_project.rb +0 -11
  106. data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
  107. data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
  108. data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
  109. data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
  110. data/spec/faked_project/spec/faked_spec.rb +0 -11
  111. data/spec/faked_project/spec/forking_spec.rb +0 -8
  112. data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
  113. data/spec/faked_project/spec/some_class_spec.rb +0 -13
  114. data/spec/faked_project/spec/spec_helper.rb +0 -11
  115. data/spec/faked_project/test/faked_test.rb +0 -11
  116. data/spec/faked_project/test/meta_magic_test.rb +0 -13
  117. data/spec/faked_project/test/some_class_test.rb +0 -15
  118. data/spec/faked_project/test/test_helper.rb +0 -12
  119. data/spec/file_list_spec.rb +0 -50
  120. data/spec/filters_spec.rb +0 -202
  121. data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
  122. data/spec/fixtures/app/models/user.rb +0 -10
  123. data/spec/fixtures/deleted_source_sample.rb +0 -15
  124. data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
  125. data/spec/fixtures/frameworks/rspec_good.rb +0 -9
  126. data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
  127. data/spec/fixtures/frameworks/testunit_good.rb +0 -9
  128. data/spec/fixtures/iso-8859.rb +0 -3
  129. data/spec/fixtures/never.rb +0 -2
  130. data/spec/fixtures/resultset1.rb +0 -4
  131. data/spec/fixtures/resultset2.rb +0 -4
  132. data/spec/fixtures/sample.rb +0 -16
  133. data/spec/fixtures/skipped.rb +0 -4
  134. data/spec/fixtures/skipped_and_executed.rb +0 -8
  135. data/spec/fixtures/utf-8.rb +0 -3
  136. data/spec/helper.rb +0 -26
  137. data/spec/last_run_spec.rb +0 -48
  138. data/spec/lines_classifier_spec.rb +0 -103
  139. data/spec/multi_formatter_spec.rb +0 -20
  140. data/spec/raw_coverage_spec.rb +0 -92
  141. data/spec/result_merger_spec.rb +0 -171
  142. data/spec/result_spec.rb +0 -209
  143. data/spec/return_codes_spec.rb +0 -34
  144. data/spec/simplecov_spec.rb +0 -109
  145. data/spec/source_file_line_spec.rb +0 -155
  146. data/spec/source_file_spec.rb +0 -145
  147. 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,6 +0,0 @@
1
- Feature: Foo
2
-
3
- Scenario: Test stuff
4
- Given I want to keep stuff simple
5
- When I write my cukes for the fake project
6
- Then I make all necessary tests in a single step
@@ -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
- class UntestedClass
2
- def initialize(yogurts)
3
- @yogurts = yogurts
4
- end
5
-
6
- def power_level
7
- @yogurts.map do |yo|
8
- yo.experience_points**2
9
- end.reduce(0, &:+)
10
- end
11
- 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,8 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "forking" do
4
- it do
5
- # TODO: The defined?(RUBY_ENGINE) check can be dropped for simplecov 1.0.0
6
- Process.waitpid(Kernel.fork {}) unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
7
- end
8
- 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,11 +0,0 @@
1
- require "test_helper"
2
-
3
- class FakedTest < Test::Unit::TestCase
4
- def test_something
5
- assert_equal "bar", FakedProject.foo
6
- end
7
-
8
- def test_framework_specific
9
- assert_equal "Only tested in Test/Unit", FrameworkSpecific.test_unit
10
- end
11
- end
@@ -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"
@@ -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
@@ -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