simplecov 0.4.2 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/.rvmrc +1 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +64 -0
- data/Gemfile +7 -0
- data/README.rdoc +83 -66
- data/Rakefile +3 -7
- data/cucumber.yml +13 -0
- data/features/config_adapters.feature +44 -0
- data/features/config_autoload.feature +46 -0
- data/features/config_command_name.feature +33 -0
- data/features/config_coverage_dir.feature +20 -0
- data/features/config_deactivate_merging.feature +42 -0
- data/features/config_merge_timeout.feature +38 -0
- data/features/config_project_name.feature +27 -0
- data/features/config_styles.feature +93 -0
- data/features/cucumber_basic.feature +29 -0
- data/features/merging_test_unit_and_rspec.feature +44 -0
- data/features/rspec_basic.feature +31 -0
- data/features/rspec_groups_and_filters_basic.feature +29 -0
- data/features/rspec_groups_and_filters_complex.feature +35 -0
- data/features/rspec_without_simplecov.feature +20 -0
- data/features/step_definitions/html_steps.rb +42 -0
- data/features/step_definitions/simplecov_steps.rb +61 -0
- data/features/step_definitions/transformers.rb +13 -0
- data/features/step_definitions/web_steps.rb +64 -0
- data/features/support/env.rb +26 -0
- data/features/test_unit_basic.feature +34 -0
- data/features/test_unit_groups_and_filters_basic.feature +29 -0
- data/features/test_unit_groups_and_filters_complex.feature +35 -0
- data/features/test_unit_without_simplecov.feature +20 -0
- data/lib/simplecov.rb +15 -30
- data/lib/simplecov/adapters.rb +3 -26
- data/lib/simplecov/command_guesser.rb +2 -2
- data/lib/simplecov/configuration.rb +21 -21
- data/lib/simplecov/defaults.rb +48 -0
- data/lib/simplecov/file_list.rb +44 -0
- data/lib/simplecov/filter.rb +5 -5
- data/lib/simplecov/formatter.rb +1 -1
- data/lib/simplecov/formatter/simple_formatter.rb +1 -1
- data/lib/simplecov/jruby_float_fix.rb +1 -1
- data/lib/simplecov/merge_helpers.rb +4 -4
- data/lib/simplecov/result.rb +33 -30
- data/lib/simplecov/result_merger.rb +30 -13
- data/lib/simplecov/source_file.rb +78 -21
- data/lib/simplecov/version.rb +1 -1
- data/simplecov.gemspec +25 -22
- data/test/faked_project/Gemfile +6 -0
- data/test/faked_project/Rakefile +8 -0
- data/test/faked_project/cucumber.yml +13 -0
- data/test/faked_project/features/step_definitions/my_steps.rb +23 -0
- data/test/faked_project/features/support/env.rb +12 -0
- data/test/faked_project/features/test_stuff.feature +6 -0
- data/test/faked_project/lib/faked_project.rb +11 -0
- data/test/faked_project/lib/faked_project/framework_specific.rb +18 -0
- data/test/faked_project/lib/faked_project/meta_magic.rb +24 -0
- data/test/faked_project/lib/faked_project/some_class.rb +29 -0
- data/test/faked_project/spec/faked_spec.rb +11 -0
- data/test/faked_project/spec/meta_magic_spec.rb +10 -0
- data/test/faked_project/spec/some_class_spec.rb +10 -0
- data/test/faked_project/spec/spec_helper.rb +15 -0
- data/test/faked_project/test/faked_test.rb +11 -0
- data/test/faked_project/test/meta_magic_test.rb +13 -0
- data/test/faked_project/test/some_class_test.rb +15 -0
- data/test/faked_project/test/test_helper.rb +16 -0
- data/test/fixtures/app/controllers/sample_controller.rb +2 -2
- data/test/fixtures/app/models/user.rb +2 -2
- data/test/fixtures/frameworks/rspec_bad.rb +1 -1
- data/test/fixtures/frameworks/rspec_good.rb +1 -1
- data/test/fixtures/frameworks/testunit_bad.rb +1 -1
- data/test/fixtures/frameworks/testunit_good.rb +1 -1
- data/test/fixtures/resultset1.rb +1 -1
- data/test/fixtures/resultset2.rb +1 -1
- data/test/fixtures/sample.rb +8 -2
- data/test/helper.rb +17 -4
- data/test/shoulda_macros.rb +2 -2
- data/test/test_1_8_fallbacks.rb +3 -3
- data/test/test_command_guesser.rb +3 -3
- data/test/test_file_list.rb +24 -0
- data/test/test_filters.rb +18 -13
- data/test/test_merge_helpers.rb +23 -23
- data/test/test_result.rb +40 -31
- data/test/test_return_codes.rb +5 -5
- data/test/test_source_file.rb +39 -15
- data/test/test_source_file_line.rb +22 -22
- metadata +191 -53
- data/.document +0 -5
data/lib/simplecov.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
1
|
#
|
4
2
|
# Code coverage for ruby 1.9. Please check out README for a full introduction.
|
5
3
|
#
|
6
4
|
module SimpleCov
|
7
5
|
# Indicates invalid coverage data
|
8
6
|
class CoverageDataError < StandardError; end;
|
9
|
-
|
7
|
+
|
10
8
|
class << self
|
11
9
|
attr_accessor :running#, :result # TODO: Remove result?
|
12
|
-
|
10
|
+
|
13
11
|
#
|
14
12
|
# Sets up SimpleCov to run against your project.
|
15
13
|
# You can optionally specify an adapter to use as well as configuration with a block:
|
@@ -29,7 +27,7 @@ module SimpleCov
|
|
29
27
|
#
|
30
28
|
def start(adapter=nil, &block)
|
31
29
|
return false unless SimpleCov.usable?
|
32
|
-
|
30
|
+
|
33
31
|
require 'coverage'
|
34
32
|
load_adapter(adapter) unless adapter.nil?
|
35
33
|
Coverage.start
|
@@ -37,7 +35,7 @@ module SimpleCov
|
|
37
35
|
@result = nil
|
38
36
|
self.running = true
|
39
37
|
end
|
40
|
-
|
38
|
+
|
41
39
|
#
|
42
40
|
# Returns the result for the current coverage run, merging it across test suites
|
43
41
|
# from cache using SimpleCov::ResultMerger if use_merging is activated (default)
|
@@ -55,7 +53,7 @@ module SimpleCov
|
|
55
53
|
ensure
|
56
54
|
self.running = false
|
57
55
|
end
|
58
|
-
|
56
|
+
|
59
57
|
#
|
60
58
|
# Applies the configured filters to the given array of SimpleCov::SourceFile items
|
61
59
|
#
|
@@ -64,9 +62,9 @@ module SimpleCov
|
|
64
62
|
filters.each do |filter|
|
65
63
|
result = result.select {|source_file| filter.passes?(source_file) }
|
66
64
|
end
|
67
|
-
result
|
65
|
+
SimpleCov::FileList.new result
|
68
66
|
end
|
69
|
-
|
67
|
+
|
70
68
|
#
|
71
69
|
# Applies the configured groups to the given array of SimpleCov::SourceFile items
|
72
70
|
#
|
@@ -74,22 +72,22 @@ module SimpleCov
|
|
74
72
|
grouped = {}
|
75
73
|
grouped_files = []
|
76
74
|
groups.each do |name, filter|
|
77
|
-
grouped[name] = files.select {|source_file| !filter.passes?(source_file)}
|
75
|
+
grouped[name] = SimpleCov::FileList.new(files.select {|source_file| !filter.passes?(source_file)})
|
78
76
|
grouped_files += grouped[name]
|
79
77
|
end
|
80
78
|
if groups.length > 0 and (other_files = files.reject {|source_file| grouped_files.include?(source_file)}).length > 0
|
81
|
-
grouped["Ungrouped"] = other_files
|
79
|
+
grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
|
82
80
|
end
|
83
81
|
grouped
|
84
82
|
end
|
85
|
-
|
86
|
-
#
|
83
|
+
|
84
|
+
#
|
87
85
|
# Applies the adapter of given name on SimpleCov configuration
|
88
86
|
#
|
89
87
|
def load_adapter(name)
|
90
88
|
adapters.load(name)
|
91
89
|
end
|
92
|
-
|
90
|
+
|
93
91
|
#
|
94
92
|
# Checks whether we're on a proper version of ruby (1.9+) and returns false if this is not the case,
|
95
93
|
# also printing an appropriate warning
|
@@ -110,6 +108,7 @@ require 'simplecov/configuration'
|
|
110
108
|
SimpleCov.send :extend, SimpleCov::Configuration
|
111
109
|
require 'simplecov/adapters'
|
112
110
|
require 'simplecov/source_file'
|
111
|
+
require 'simplecov/file_list'
|
113
112
|
require 'simplecov/result'
|
114
113
|
require 'simplecov/filter'
|
115
114
|
require 'simplecov/formatter'
|
@@ -118,19 +117,5 @@ require 'simplecov/result_merger'
|
|
118
117
|
require 'simplecov/command_guesser'
|
119
118
|
require 'simplecov/version'
|
120
119
|
|
121
|
-
# Load
|
122
|
-
require 'simplecov
|
123
|
-
|
124
|
-
# Default configuration
|
125
|
-
SimpleCov.configure do
|
126
|
-
formatter SimpleCov::Formatter::HTMLFormatter
|
127
|
-
# Exclude files outside of SimpleCov.root
|
128
|
-
load_adapter 'root_filter'
|
129
|
-
end
|
130
|
-
|
131
|
-
at_exit do
|
132
|
-
# Store the exit status of the test run since it goes away after calling the at_exit proc...
|
133
|
-
@exit_status = $!.status if $!.is_a?(SystemExit)
|
134
|
-
SimpleCov.at_exit.call
|
135
|
-
exit @exit_status if @exit_status # Force exit with stored status (see github issue #5)
|
136
|
-
end
|
120
|
+
# Load default config
|
121
|
+
require 'simplecov/defaults'
|
data/lib/simplecov/adapters.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# Adapters are glorified SimpleCov configuration procs that can be easily
|
3
3
|
# loaded using SimpleCov.start :rails and defined using
|
4
4
|
# SimpleCov.adapters.define :foo do
|
5
5
|
# # SimpleCov configuration here, same as in SimpleCov.configure
|
6
6
|
# end
|
7
7
|
#
|
8
8
|
class SimpleCov::Adapters < Hash
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Define a SimpleCov adapter:
|
11
11
|
# SimpleCov.adapters.define 'rails' do
|
12
12
|
# # Same as SimpleCov.configure do .. here
|
@@ -17,7 +17,7 @@ class SimpleCov::Adapters < Hash
|
|
17
17
|
raise "SimpleCov Adapter '#{name}' is already defined" unless self[name].nil?
|
18
18
|
self[name] = blk
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
#
|
22
22
|
# Applies the adapter of given name on SimpleCov.configure
|
23
23
|
#
|
@@ -27,26 +27,3 @@ class SimpleCov::Adapters < Hash
|
|
27
27
|
SimpleCov.configure(&self[name])
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
SimpleCov.adapters.define 'root_filter' do
|
32
|
-
# Exclude all files outside of simplecov root
|
33
|
-
add_filter do |src|
|
34
|
-
!(src.filename =~ /^#{SimpleCov.root}/)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
SimpleCov.adapters.define 'rails' do
|
39
|
-
add_filter '/test/'
|
40
|
-
add_filter '/features/'
|
41
|
-
add_filter '/spec/'
|
42
|
-
add_filter '/config/'
|
43
|
-
add_filter '/db/'
|
44
|
-
add_filter '/autotest/'
|
45
|
-
add_filter '/vendor/bundle/'
|
46
|
-
|
47
|
-
add_group 'Controllers', 'app/controllers'
|
48
|
-
add_group 'Models', 'app/models'
|
49
|
-
add_group 'Helpers', 'app/helpers'
|
50
|
-
add_group 'Libraries', 'lib'
|
51
|
-
add_group 'Plugins', 'vendor/plugins'
|
52
|
-
end
|
@@ -6,7 +6,7 @@ require 'fileutils'
|
|
6
6
|
#
|
7
7
|
module SimpleCov::Configuration
|
8
8
|
attr_writer :filters, :groups, :formatter
|
9
|
-
|
9
|
+
|
10
10
|
#
|
11
11
|
# The root for the project. This defaults to the
|
12
12
|
# current working directory.
|
@@ -17,7 +17,7 @@ module SimpleCov::Configuration
|
|
17
17
|
return @root if @root and root.nil?
|
18
18
|
@root = File.expand_path(root || Dir.getwd)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
#
|
22
22
|
# The name of the output and cache directory. Defaults to 'coverage'
|
23
23
|
#
|
@@ -27,7 +27,7 @@ module SimpleCov::Configuration
|
|
27
27
|
return @coverage_dir if @coverage_dir and dir.nil?
|
28
28
|
@coverage_dir = (dir || 'coverage')
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
#
|
32
32
|
# Returns the full path to the output directory using SimpleCov.root
|
33
33
|
# and SimpleCov.coverage_dir, so you can adjust this by configuring those
|
@@ -38,14 +38,14 @@ module SimpleCov::Configuration
|
|
38
38
|
FileUtils.mkdir_p coverage_path
|
39
39
|
coverage_path
|
40
40
|
end
|
41
|
-
|
42
|
-
#
|
41
|
+
|
42
|
+
#
|
43
43
|
# Returns the list of configured filters. Add filters using SimpleCov.add_filter.
|
44
44
|
#
|
45
45
|
def filters
|
46
46
|
@filters ||= []
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
# The name of the command (a.k.a. Test Suite) currently running. Used for result
|
50
50
|
# merging and caching. It first tries to make a guess based upon the command line
|
51
51
|
# arguments the current test suite is running on and should automatically detect
|
@@ -60,7 +60,7 @@ module SimpleCov::Configuration
|
|
60
60
|
@name ||= SimpleCov::CommandGuesser.guess("#{$0} #{ARGV.join(" ")}")
|
61
61
|
@name
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
#
|
65
65
|
# Gets or sets the configured formatter.
|
66
66
|
#
|
@@ -72,21 +72,21 @@ module SimpleCov::Configuration
|
|
72
72
|
raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
|
73
73
|
@formatter
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
#
|
77
77
|
# Returns the configured groups. Add groups using SimpleCov.add_group
|
78
78
|
#
|
79
79
|
def groups
|
80
80
|
@groups ||= {}
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
#
|
84
84
|
# Returns the hash of available adapters
|
85
85
|
#
|
86
86
|
def adapters
|
87
87
|
@adapters ||= SimpleCov::Adapters.new
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
#
|
91
91
|
# Allows you to configure simplecov in a block instead of prepending SimpleCov to all config methods
|
92
92
|
# you're calling.
|
@@ -102,7 +102,7 @@ module SimpleCov::Configuration
|
|
102
102
|
return false unless SimpleCov.usable?
|
103
103
|
instance_exec(&block)
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
#
|
107
107
|
# Gets or sets the behavior to process coverage results.
|
108
108
|
#
|
@@ -119,7 +119,7 @@ module SimpleCov::Configuration
|
|
119
119
|
@at_exit = block if block_given?
|
120
120
|
@at_exit ||= Proc.new { SimpleCov.result.format! }
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
#
|
124
124
|
# Returns the project name - currently assuming the last dirname in
|
125
125
|
# the SimpleCov.root is this.
|
@@ -129,7 +129,7 @@ module SimpleCov::Configuration
|
|
129
129
|
@project_name = new_name if new_name.kind_of?(String)
|
130
130
|
@project_name ||= File.basename(root.split('/').last).capitalize.gsub('_', ' ')
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
#
|
134
134
|
# Defines whether to use result merging so all your test suites (test:units, test:functionals, cucumber, ...)
|
135
135
|
# are joined and combined into a single coverage report
|
@@ -138,10 +138,10 @@ module SimpleCov::Configuration
|
|
138
138
|
@use_merging = use unless use.nil? # Set if param given
|
139
139
|
@use_merging = true if @use_merging != false
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
#
|
143
143
|
# Defines them maximum age (in seconds) of a resultset to still be included in merged results.
|
144
|
-
# i.e. If you run cucumber features, then later rake test, if the stored cucumber resultset is
|
144
|
+
# i.e. If you run cucumber features, then later rake test, if the stored cucumber resultset is
|
145
145
|
# more seconds ago than specified here, it won't be taken into account when merging (and is also
|
146
146
|
# purged from the resultset cache)
|
147
147
|
#
|
@@ -155,11 +155,11 @@ module SimpleCov::Configuration
|
|
155
155
|
@merge_timeout = seconds if !seconds.nil? and seconds.kind_of?(Fixnum)
|
156
156
|
@merge_timeout ||= 600
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
#
|
160
160
|
# Add a filter to the processing chain.
|
161
161
|
# There are three ways to define a filter:
|
162
|
-
#
|
162
|
+
#
|
163
163
|
# * as a String that will then be matched against all source files' file paths,
|
164
164
|
# SimpleCov.add_filter 'app/models' # will reject all your models
|
165
165
|
# * as a block which will be passed the source file in question and should either
|
@@ -173,7 +173,7 @@ module SimpleCov::Configuration
|
|
173
173
|
def add_filter(filter_argument=nil, &filter_proc)
|
174
174
|
filters << parse_filter(filter_argument, &filter_proc)
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
#
|
178
178
|
# Define a group for files. Works similar to add_filter, only that the first
|
179
179
|
# argument is the desired group name and files PASSING the filter end up in the group
|
@@ -182,7 +182,7 @@ module SimpleCov::Configuration
|
|
182
182
|
def add_group(group_name, filter_argument=nil, &filter_proc)
|
183
183
|
groups[group_name] = parse_filter(filter_argument, &filter_proc)
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
#
|
187
187
|
# The actal filter processor. Not meant for direct use
|
188
188
|
#
|
@@ -195,6 +195,6 @@ module SimpleCov::Configuration
|
|
195
195
|
SimpleCov::BlockFilter.new(filter_proc)
|
196
196
|
else
|
197
197
|
raise ArgumentError, "Please specify either a string or a block to filter with"
|
198
|
-
end
|
198
|
+
end
|
199
199
|
end
|
200
|
-
end
|
200
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Load default formatter gem
|
2
|
+
require 'simplecov-html'
|
3
|
+
|
4
|
+
SimpleCov.adapters.define 'root_filter' do
|
5
|
+
# Exclude all files outside of simplecov root
|
6
|
+
add_filter do |src|
|
7
|
+
!(src.filename =~ /^#{SimpleCov.root}/)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
SimpleCov.adapters.define 'test_frameworks' do
|
12
|
+
add_filter '/test/'
|
13
|
+
add_filter '/features/'
|
14
|
+
add_filter '/spec/'
|
15
|
+
add_filter '/autotest/'
|
16
|
+
end
|
17
|
+
|
18
|
+
SimpleCov.adapters.define 'rails' do
|
19
|
+
load_adapter 'test_frameworks'
|
20
|
+
|
21
|
+
add_filter '/config/'
|
22
|
+
add_filter '/db/'
|
23
|
+
add_filter '/vendor/bundle/'
|
24
|
+
|
25
|
+
add_group 'Controllers', 'app/controllers'
|
26
|
+
add_group 'Models', 'app/models'
|
27
|
+
add_group 'Helpers', 'app/helpers'
|
28
|
+
add_group 'Libraries', 'lib'
|
29
|
+
add_group 'Plugins', 'vendor/plugins'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Default configuration
|
33
|
+
SimpleCov.configure do
|
34
|
+
formatter SimpleCov::Formatter::HTMLFormatter
|
35
|
+
# Exclude files outside of SimpleCov.root
|
36
|
+
load_adapter 'root_filter'
|
37
|
+
end
|
38
|
+
|
39
|
+
at_exit do
|
40
|
+
# Store the exit status of the test run since it goes away after calling the at_exit proc...
|
41
|
+
@exit_status = $!.status if $!.is_a?(SystemExit)
|
42
|
+
SimpleCov.at_exit.call
|
43
|
+
exit @exit_status if @exit_status # Force exit with stored status (see github issue #5)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Autoload config from .simplecov if present
|
47
|
+
config_path = File.join(SimpleCov.root, '.simplecov')
|
48
|
+
load config_path if File.exist?(config_path)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# An array of SimpleCov SourceFile instances with additional collection helper
|
2
|
+
# methods for calculating coverage across them etc.
|
3
|
+
class SimpleCov::FileList < Array
|
4
|
+
# Returns the count of lines that have coverage
|
5
|
+
def covered_lines
|
6
|
+
return 0.0 if empty?
|
7
|
+
map {|f| f.covered_lines.count }.inject(&:+)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns the count of lines that have been missed
|
11
|
+
def missed_lines
|
12
|
+
return 0.0 if empty?
|
13
|
+
map {|f| f.missed_lines.count }.inject(&:+)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the count of lines that are not relevant for coverage
|
17
|
+
def never_lines
|
18
|
+
return 0.0 if empty?
|
19
|
+
map {|f| f.never_lines.count }.inject(&:+)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the count of skipped lines
|
23
|
+
def skipped_lines
|
24
|
+
return 0.0 if empty?
|
25
|
+
map {|f| f.skipped_lines.count }.inject(&:+)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the overall amount of relevant lines of code across all files in this list
|
29
|
+
def lines_of_code
|
30
|
+
covered_lines + missed_lines
|
31
|
+
end
|
32
|
+
|
33
|
+
# Computes the coverage based upon lines covered and lines missed
|
34
|
+
def covered_percent
|
35
|
+
return 100.0 if empty? or lines_of_code == 0
|
36
|
+
covered_lines * 100.0 / lines_of_code
|
37
|
+
end
|
38
|
+
|
39
|
+
# Computes the strength (hits / line) based upon lines covered and lines missed
|
40
|
+
def covered_strength
|
41
|
+
return 0 if empty? or lines_of_code == 0
|
42
|
+
map {|f| f.covered_strength }.inject(&:+) / size
|
43
|
+
end
|
44
|
+
end
|
data/lib/simplecov/filter.rb
CHANGED
@@ -2,7 +2,7 @@ module SimpleCov
|
|
2
2
|
#
|
3
3
|
# Base filter class. Inherit from this to create custom filters,
|
4
4
|
# and overwrite the passes?(source_file) instance method
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# # A sample class that rejects all source files.
|
7
7
|
# class StupidFilter < SimpleCov::Filter
|
8
8
|
# def passes?(source_file)
|
@@ -15,12 +15,12 @@ module SimpleCov
|
|
15
15
|
def initialize(filter_argument)
|
16
16
|
@filter_argument = filter_argument
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def passes?(source_file)
|
20
20
|
raise "The base filter class is not intended for direct use"
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
class StringFilter < SimpleCov::Filter
|
25
25
|
# Returns true when the given source file's filename matches the
|
26
26
|
# string configured when initializing this Filter with StringFilter.new('somestring)
|
@@ -28,7 +28,7 @@ module SimpleCov
|
|
28
28
|
!(source_file.filename =~ /#{filter_argument}/)
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
class BlockFilter < SimpleCov::Filter
|
33
33
|
# Returns true if the block given when initializing this filter with BlockFilter.new {|src_file| ... }
|
34
34
|
# returns true for the given source file.
|
@@ -36,4 +36,4 @@ module SimpleCov
|
|
36
36
|
!filter_argument.call(source_file)
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|