simplecov 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +26 -2
- data/CONTRIBUTING.md +12 -9
- data/ISSUE_TEMPLATE.md +23 -0
- data/README.md +42 -16
- data/doc/alternate-formatters.md +16 -1
- data/lib/simplecov/command_guesser.rb +2 -0
- data/lib/simplecov/configuration.rb +2 -0
- data/lib/simplecov/defaults.rb +9 -80
- data/lib/simplecov/exit_codes.rb +2 -0
- data/lib/simplecov/file_list.rb +2 -0
- data/lib/simplecov/filter.rb +3 -1
- data/lib/simplecov/formatter/multi_formatter.rb +2 -0
- data/lib/simplecov/formatter/simple_formatter.rb +2 -0
- data/lib/simplecov/formatter.rb +2 -0
- data/lib/simplecov/jruby_fix.rb +2 -0
- data/lib/simplecov/last_run.rb +2 -0
- data/lib/simplecov/lines_classifier.rb +19 -3
- data/lib/simplecov/load_global_config.rb +2 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles/bundler_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/profiles.rb +2 -0
- data/lib/simplecov/railtie.rb +2 -0
- data/lib/simplecov/railties/tasks.rake +2 -0
- data/lib/simplecov/raw_coverage.rb +2 -0
- data/lib/simplecov/result.rb +2 -0
- data/lib/simplecov/result_merger.rb +2 -0
- data/lib/simplecov/source_file.rb +3 -1
- data/lib/simplecov/version.rb +3 -1
- data/lib/simplecov.rb +91 -0
- metadata +22 -117
- 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/MIT-LICENSE +0 -20
- data/Rakefile +0 -41
- 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/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/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/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/lib/faked_project.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 -172
- 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,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 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,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,172 +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
|
-
describe ".class_for_argument" do
|
|
159
|
-
it "returns SimpleCov::StringFilter for a string" do
|
|
160
|
-
expect(SimpleCov::Filter.class_for_argument("filestring")).to eq(SimpleCov::StringFilter)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it "returns SimpleCov::RegexFilter for a string" do
|
|
164
|
-
expect(SimpleCov::Filter.class_for_argument(/regex/)).to eq(SimpleCov::RegexFilter)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it "returns SimpleCov::RegexFilter for a string" do
|
|
168
|
-
expect(SimpleCov::Filter.class_for_argument(%w[file1 file2])).to eq(SimpleCov::ArrayFilter)
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", ".."))
|
|
2
|
-
require "lib/simplecov"
|
|
3
|
-
SimpleCov.start { command_name "Test" }
|
|
4
|
-
|
|
5
|
-
dir = File.expand_path(File.dirname(__FILE__))
|
|
6
|
-
file = File.join(dir, "generated_buddha.rb")
|
|
7
|
-
code = %{
|
|
8
|
-
def kill_the_buddha(z)
|
|
9
|
-
z**z
|
|
10
|
-
end
|
|
11
|
-
}
|
|
12
|
-
File.open(file, "w") { |f| f.print code }
|
|
13
|
-
load file
|
|
14
|
-
File.unlink file
|
|
15
|
-
raise unless kill_the_buddha(3) == 27
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
|
2
|
-
require "lib/simplecov"
|
|
3
|
-
require "rspec"
|
|
4
|
-
SimpleCov.start
|
|
5
|
-
describe "exit status" do
|
|
6
|
-
it "should exit with a non-zero exit status when assertion fails" do
|
|
7
|
-
expect(1).to eq(2)
|
|
8
|
-
end
|
|
9
|
-
end
|
data/spec/fixtures/iso-8859.rb
DELETED
data/spec/fixtures/never.rb
DELETED
data/spec/fixtures/resultset1.rb
DELETED
data/spec/fixtures/resultset2.rb
DELETED
data/spec/fixtures/sample.rb
DELETED
data/spec/fixtures/skipped.rb
DELETED
data/spec/fixtures/utf-8.rb
DELETED
data/spec/helper.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require "rspec"
|
|
2
|
-
# loaded before simplecov to also capture parse time warnings
|
|
3
|
-
require "support/fail_rspec_on_ruby_warning"
|
|
4
|
-
require "simplecov"
|
|
5
|
-
|
|
6
|
-
SimpleCov.coverage_dir("tmp/coverage")
|
|
7
|
-
|
|
8
|
-
def source_fixture(filename)
|
|
9
|
-
File.expand_path(File.join(File.dirname(__FILE__), "fixtures", filename))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
|
|
13
|
-
require "stringio"
|
|
14
|
-
|
|
15
|
-
def capture_stderr
|
|
16
|
-
# The output stream must be an IO-like object. In this case we capture it in
|
|
17
|
-
# an in-memory IO object so we can return the string value. You can assign any
|
|
18
|
-
# IO object here.
|
|
19
|
-
previous_stderr = $stderr
|
|
20
|
-
$stderr = StringIO.new
|
|
21
|
-
yield
|
|
22
|
-
$stderr.string
|
|
23
|
-
ensure
|
|
24
|
-
# Restore the previous value of stderr (typically equal to STDERR).
|
|
25
|
-
$stderr = previous_stderr
|
|
26
|
-
end
|
data/spec/last_run_spec.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require "helper"
|
|
2
|
-
|
|
3
|
-
if SimpleCov.usable?
|
|
4
|
-
describe SimpleCov::LastRun do
|
|
5
|
-
subject { SimpleCov::LastRun }
|
|
6
|
-
|
|
7
|
-
it "defines a last_run_path" do
|
|
8
|
-
expect(subject.last_run_path).to include "tmp/coverage/.last_run.json"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "writes json to its last_run_path that can be parsed again" do
|
|
12
|
-
structure = [{"key" => "value"}]
|
|
13
|
-
subject.write(structure)
|
|
14
|
-
file_contents = File.read(subject.last_run_path)
|
|
15
|
-
expect(JSON.parse(file_contents)).to eq structure
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "reading" do
|
|
19
|
-
context "but the last_run file does not exist" do
|
|
20
|
-
before { File.delete(subject.last_run_path) if File.exist?(subject.last_run_path) }
|
|
21
|
-
|
|
22
|
-
it "returns nil" do
|
|
23
|
-
expect(subject.read).to be_nil
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context "a non empty result" do
|
|
28
|
-
before { subject.write([]) }
|
|
29
|
-
|
|
30
|
-
it "reads json from its last_run_path" do
|
|
31
|
-
expect(subject.read).to eq([])
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "an empty result" do
|
|
36
|
-
before do
|
|
37
|
-
File.open(subject.last_run_path, "w+") do |f|
|
|
38
|
-
f.puts ""
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "returns nil" do
|
|
43
|
-
expect(subject.read).to be_nil
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|