simplecov 0.9.1 → 0.10.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 +7 -7
- data/.gitignore +0 -1
- data/.rubocop.yml +69 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +59 -21
- data/Gemfile +22 -15
- data/MIT-LICENSE +1 -1
- data/README.md +198 -176
- data/Rakefile +17 -8
- data/doc/alternate-formatters.md +36 -0
- data/doc/commercial-services.md +20 -0
- data/doc/editor-integration.md +13 -0
- data/features/rspec_basic.feature +3 -2
- data/features/rspec_groups_and_filters_complex.feature +2 -0
- data/features/rspec_groups_using_filter_class.feature +3 -2
- data/features/step_definitions/html_steps.rb +6 -7
- data/features/step_definitions/simplecov_steps.rb +18 -16
- data/features/step_definitions/transformers.rb +2 -2
- data/features/step_definitions/web_steps.rb +4 -4
- data/features/support/env.rb +18 -15
- data/lib/simplecov/command_guesser.rb +33 -34
- data/lib/simplecov/configuration.rb +238 -234
- data/lib/simplecov/defaults.rb +37 -36
- data/lib/simplecov/exit_codes.rb +7 -5
- data/lib/simplecov/file_list.rb +38 -36
- data/lib/simplecov/filter.rb +12 -2
- data/lib/simplecov/formatter/simple_formatter.rb +1 -1
- data/lib/simplecov/formatter.rb +2 -2
- data/lib/simplecov/jruby_fix.rb +4 -4
- data/lib/simplecov/last_run.rb +15 -13
- data/lib/simplecov/merge_helpers.rb +26 -27
- data/lib/simplecov/no_defaults.rb +2 -2
- data/lib/simplecov/profiles.rb +21 -19
- data/lib/simplecov/railtie.rb +1 -1
- data/lib/simplecov/railties/tasks.rake +7 -7
- data/lib/simplecov/result.rb +5 -5
- data/lib/simplecov/result_merger.rb +65 -62
- data/lib/simplecov/source_file.rb +23 -24
- data/lib/simplecov/version.rb +20 -1
- data/lib/simplecov.rb +35 -24
- data/simplecov.gemspec +15 -12
- data/test/faked_project/Gemfile +5 -5
- data/test/faked_project/Rakefile +4 -4
- data/test/faked_project/features/step_definitions/my_steps.rb +3 -4
- data/test/faked_project/features/support/env.rb +5 -5
- data/test/faked_project/lib/faked_project/some_class.rb +3 -4
- data/test/faked_project/lib/faked_project.rb +1 -1
- data/test/faked_project/spec/faked_spec.rb +2 -2
- data/test/faked_project/spec/forking_spec.rb +7 -0
- data/test/faked_project/spec/meta_magic_spec.rb +1 -1
- data/test/faked_project/spec/some_class_spec.rb +3 -3
- data/test/faked_project/spec/spec_helper.rb +4 -8
- data/test/faked_project/test/faked_test.rb +2 -2
- data/test/faked_project/test/meta_magic_test.rb +1 -1
- data/test/faked_project/test/some_class_test.rb +3 -3
- data/test/faked_project/test/test_helper.rb +5 -9
- data/test/fixtures/app/controllers/sample_controller.rb +1 -1
- data/test/fixtures/app/models/user.rb +1 -1
- data/test/fixtures/deleted_source_sample.rb +3 -3
- data/test/fixtures/frameworks/rspec_bad.rb +4 -4
- data/test/fixtures/frameworks/rspec_good.rb +4 -4
- data/test/fixtures/frameworks/testunit_bad.rb +3 -3
- data/test/fixtures/frameworks/testunit_good.rb +3 -3
- data/test/fixtures/resultset2.rb +0 -1
- data/test/fixtures/sample.rb +1 -1
- data/test/fixtures/utf-8.rb +1 -1
- data/test/helper.rb +9 -11
- data/test/test_1_8_fallbacks.rb +7 -7
- data/test/test_command_guesser.rb +8 -8
- data/test/test_deleted_source.rb +3 -3
- data/test/test_file_list.rb +9 -7
- data/test/test_filters.rb +30 -14
- data/test/test_merge_helpers.rb +31 -24
- data/test/test_result.rb +32 -23
- data/test/test_return_codes.rb +10 -6
- data/test/test_source_file.rb +5 -38
- data/test/test_source_file_line.rb +17 -17
- metadata +146 -64
- data/lib/simplecov/json.rb +0 -27
|
@@ -25,26 +25,26 @@ module SimpleCov
|
|
|
25
25
|
alias_method :number, :line_number
|
|
26
26
|
|
|
27
27
|
def initialize(src, line_number, coverage)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
fail ArgumentError, "Only String accepted for source" unless src.is_a?(String)
|
|
29
|
+
fail ArgumentError, "Only Fixnum accepted for line_number" unless line_number.is_a?(Fixnum)
|
|
30
|
+
fail ArgumentError, "Only Fixnum and nil accepted for coverage" unless coverage.is_a?(Fixnum) || coverage.nil?
|
|
31
31
|
@src, @line_number, @coverage = src, line_number, coverage
|
|
32
32
|
@skipped = false
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Returns true if this is a line that should have been covered, but was not
|
|
36
36
|
def missed?
|
|
37
|
-
|
|
37
|
+
!never? && !skipped? && coverage.zero?
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
# Returns true if this is a line that has been covered
|
|
41
41
|
def covered?
|
|
42
|
-
|
|
42
|
+
!never? && !skipped? && coverage > 0
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Returns true if this line is not relevant for coverage
|
|
46
46
|
def never?
|
|
47
|
-
|
|
47
|
+
!skipped? && coverage.nil?
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# Flags this line as skipped
|
|
@@ -55,16 +55,16 @@ module SimpleCov
|
|
|
55
55
|
# Returns true if this line was skipped, false otherwise. Lines are skipped if they are wrapped with
|
|
56
56
|
# # :nocov: comment lines.
|
|
57
57
|
def skipped?
|
|
58
|
-
|
|
58
|
+
!!skipped
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# The status of this line - either covered, missed, skipped or never. Useful i.e. for direct use
|
|
62
62
|
# as a css class in report generation
|
|
63
63
|
def status
|
|
64
|
-
return
|
|
65
|
-
return
|
|
66
|
-
return
|
|
67
|
-
return
|
|
64
|
+
return "skipped" if skipped?
|
|
65
|
+
return "never" if never?
|
|
66
|
+
return "missed" if missed?
|
|
67
|
+
return "covered" if covered?
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ module SimpleCov
|
|
|
78
78
|
|
|
79
79
|
def initialize(filename, coverage)
|
|
80
80
|
@filename, @coverage = filename, coverage
|
|
81
|
-
File.open(filename, "rb") {|f| @src = f.readlines }
|
|
81
|
+
File.open(filename, "rb") { |f| @src = f.readlines }
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
# Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
|
|
@@ -94,7 +94,7 @@ module SimpleCov
|
|
|
94
94
|
# Initialize lines
|
|
95
95
|
@lines = []
|
|
96
96
|
src.each_with_index do |src, i|
|
|
97
|
-
@lines << SimpleCov::SourceFile::Line.new(src, i+1, coverage[i])
|
|
97
|
+
@lines << SimpleCov::SourceFile::Line.new(src, i + 1, coverage[i])
|
|
98
98
|
end
|
|
99
99
|
process_skipped_lines!
|
|
100
100
|
@lines
|
|
@@ -103,14 +103,14 @@ module SimpleCov
|
|
|
103
103
|
|
|
104
104
|
# Access SimpleCov::SourceFile::Line source lines by line number
|
|
105
105
|
def line(number)
|
|
106
|
-
lines[number-1]
|
|
106
|
+
lines[number - 1]
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
# The coverage for this file in percent. 0 if the file has no relevant lines
|
|
110
110
|
def covered_percent
|
|
111
|
-
return 100.0 if lines.length
|
|
111
|
+
return 100.0 if lines.length.zero? || lines.length == never_lines.count
|
|
112
112
|
relevant_lines = lines.count - never_lines.count - skipped_lines.count
|
|
113
|
-
if relevant_lines
|
|
113
|
+
if relevant_lines.zero?
|
|
114
114
|
0.0
|
|
115
115
|
else
|
|
116
116
|
Float((covered_lines.count) * 100.0 / relevant_lines.to_f)
|
|
@@ -118,7 +118,7 @@ module SimpleCov
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
def covered_strength
|
|
121
|
-
return 0.0 if lines.length
|
|
121
|
+
return 0.0 if lines.length.zero? || lines.length == never_lines.count
|
|
122
122
|
|
|
123
123
|
lines_strength = 0
|
|
124
124
|
lines.each do |c|
|
|
@@ -127,7 +127,7 @@ module SimpleCov
|
|
|
127
127
|
|
|
128
128
|
effective_lines_count = Float(lines.count - never_lines.count - skipped_lines.count)
|
|
129
129
|
|
|
130
|
-
if effective_lines_count
|
|
130
|
+
if effective_lines_count.zero?
|
|
131
131
|
0.0
|
|
132
132
|
else
|
|
133
133
|
strength = lines_strength / effective_lines_count
|
|
@@ -137,24 +137,24 @@ module SimpleCov
|
|
|
137
137
|
|
|
138
138
|
# Returns all covered lines as SimpleCov::SourceFile::Line
|
|
139
139
|
def covered_lines
|
|
140
|
-
@covered_lines ||= lines.select
|
|
140
|
+
@covered_lines ||= lines.select(&:covered?)
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
# Returns all lines that should have been, but were not covered
|
|
144
144
|
# as instances of SimpleCov::SourceFile::Line
|
|
145
145
|
def missed_lines
|
|
146
|
-
@missed_lines ||= lines.select
|
|
146
|
+
@missed_lines ||= lines.select(&:missed?)
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
# Returns all lines that are not relevant for coverage as
|
|
150
150
|
# SimpleCov::SourceFile::Line instances
|
|
151
151
|
def never_lines
|
|
152
|
-
@never_lines ||= lines.select
|
|
152
|
+
@never_lines ||= lines.select(&:never?)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
# Returns all lines that were skipped as SimpleCov::SourceFile::Line instances
|
|
156
156
|
def skipped_lines
|
|
157
|
-
@skipped_lines ||= lines.select
|
|
157
|
+
@skipped_lines ||= lines.select(&:skipped?)
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
# Returns the number of relevant lines (covered + missed)
|
|
@@ -175,7 +175,7 @@ module SimpleCov
|
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
private
|
|
179
179
|
|
|
180
180
|
# ruby 1.9 could use Float#round(places) instead
|
|
181
181
|
# @return [Float]
|
|
@@ -185,4 +185,3 @@ module SimpleCov
|
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
end
|
|
188
|
-
|
data/lib/simplecov/version.rb
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
1
|
module SimpleCov
|
|
2
|
-
VERSION = "0.
|
|
2
|
+
VERSION = "0.10.0"
|
|
3
|
+
def VERSION.to_a
|
|
4
|
+
split(".").map(&:to_i)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def VERSION.major
|
|
8
|
+
to_a[0]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def VERSION.minor
|
|
12
|
+
to_a[1]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def VERSION.patch
|
|
16
|
+
to_a[2]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def VERSION.pre
|
|
20
|
+
to_a[3]
|
|
21
|
+
end
|
|
3
22
|
end
|
data/lib/simplecov.rb
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Code coverage for ruby 1.9. Please check out README for a full introduction.
|
|
3
3
|
#
|
|
4
|
+
# Coverage may be inaccurate under JRUBY.
|
|
5
|
+
if defined?(JRUBY_VERSION)
|
|
6
|
+
if ENV["JRUBY_OPTS"].to_s !~ /-Xcli.debug=true/
|
|
7
|
+
warn "Coverage may be inaccurate; Try setting JRUBY_OPTS=\"-Xcli.debug=true --debug\""
|
|
8
|
+
# see https://github.com/metricfu/metric_fu/pull/226
|
|
9
|
+
# https://github.com/jruby/jruby/issues/1196
|
|
10
|
+
# https://jira.codehaus.org/browse/JRUBY-6106
|
|
11
|
+
# https://github.com/colszowka/simplecov/issues/86
|
|
12
|
+
end
|
|
13
|
+
end
|
|
4
14
|
module SimpleCov
|
|
5
15
|
class << self
|
|
6
16
|
attr_accessor :running
|
|
17
|
+
attr_accessor :pid
|
|
7
18
|
|
|
8
19
|
#
|
|
9
20
|
# Sets up SimpleCov to run against your project.
|
|
@@ -22,12 +33,13 @@ module SimpleCov
|
|
|
22
33
|
#
|
|
23
34
|
# Please check out the RDoc for SimpleCov::Configuration to find about available config options
|
|
24
35
|
#
|
|
25
|
-
def start(profile=nil, &block)
|
|
36
|
+
def start(profile = nil, &block)
|
|
26
37
|
if SimpleCov.usable?
|
|
27
38
|
load_profile(profile) if profile
|
|
28
39
|
configure(&block) if block_given?
|
|
29
40
|
@result = nil
|
|
30
41
|
self.running = true
|
|
42
|
+
self.pid = Process.pid
|
|
31
43
|
Coverage.start
|
|
32
44
|
else
|
|
33
45
|
warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
|
|
@@ -59,7 +71,7 @@ module SimpleCov
|
|
|
59
71
|
# Otherwise, returns the result
|
|
60
72
|
#
|
|
61
73
|
def result?
|
|
62
|
-
defined?
|
|
74
|
+
defined?(@result) && @result
|
|
63
75
|
end
|
|
64
76
|
|
|
65
77
|
#
|
|
@@ -68,7 +80,7 @@ module SimpleCov
|
|
|
68
80
|
def filtered(files)
|
|
69
81
|
result = files.clone
|
|
70
82
|
filters.each do |filter|
|
|
71
|
-
result = result.reject {|source_file| filter.matches?(source_file) }
|
|
83
|
+
result = result.reject { |source_file| filter.matches?(source_file) }
|
|
72
84
|
end
|
|
73
85
|
SimpleCov::FileList.new result
|
|
74
86
|
end
|
|
@@ -80,10 +92,10 @@ module SimpleCov
|
|
|
80
92
|
grouped = {}
|
|
81
93
|
grouped_files = []
|
|
82
94
|
groups.each do |name, filter|
|
|
83
|
-
grouped[name] = SimpleCov::FileList.new(files.select {|source_file| filter.matches?(source_file)})
|
|
95
|
+
grouped[name] = SimpleCov::FileList.new(files.select { |source_file| filter.matches?(source_file) })
|
|
84
96
|
grouped_files += grouped[name]
|
|
85
97
|
end
|
|
86
|
-
if groups.length > 0
|
|
98
|
+
if groups.length > 0 && (other_files = files.reject { |source_file| grouped_files.include?(source_file) }).length > 0
|
|
87
99
|
grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
|
|
88
100
|
end
|
|
89
101
|
grouped
|
|
@@ -106,11 +118,11 @@ module SimpleCov
|
|
|
106
118
|
# provides coverage support
|
|
107
119
|
#
|
|
108
120
|
def usable?
|
|
109
|
-
return @usable if defined?
|
|
121
|
+
return @usable if defined?(@usable) && !@usable.nil?
|
|
110
122
|
|
|
111
123
|
@usable = begin
|
|
112
|
-
require
|
|
113
|
-
require
|
|
124
|
+
require "coverage"
|
|
125
|
+
require "simplecov/jruby_fix"
|
|
114
126
|
true
|
|
115
127
|
rescue LoadError
|
|
116
128
|
false
|
|
@@ -120,24 +132,23 @@ module SimpleCov
|
|
|
120
132
|
end
|
|
121
133
|
|
|
122
134
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
|
123
|
-
require
|
|
135
|
+
require "simplecov/configuration"
|
|
124
136
|
SimpleCov.send :extend, SimpleCov::Configuration
|
|
125
|
-
require
|
|
126
|
-
require
|
|
127
|
-
require
|
|
128
|
-
require
|
|
129
|
-
require
|
|
130
|
-
require
|
|
131
|
-
require
|
|
132
|
-
require
|
|
133
|
-
require
|
|
134
|
-
require
|
|
135
|
-
require
|
|
136
|
-
require
|
|
137
|
-
require 'simplecov/version'
|
|
137
|
+
require "simplecov/exit_codes"
|
|
138
|
+
require "simplecov/profiles"
|
|
139
|
+
require "simplecov/source_file"
|
|
140
|
+
require "simplecov/file_list"
|
|
141
|
+
require "simplecov/result"
|
|
142
|
+
require "simplecov/filter"
|
|
143
|
+
require "simplecov/formatter"
|
|
144
|
+
require "simplecov/last_run"
|
|
145
|
+
require "simplecov/merge_helpers"
|
|
146
|
+
require "simplecov/result_merger"
|
|
147
|
+
require "simplecov/command_guesser"
|
|
148
|
+
require "simplecov/version"
|
|
138
149
|
|
|
139
150
|
# Load default config
|
|
140
|
-
require
|
|
151
|
+
require "simplecov/defaults" unless ENV["SIMPLECOV_NO_DEFAULTS"]
|
|
141
152
|
|
|
142
153
|
# Load Rails integration (only for Rails 3, see #113)
|
|
143
|
-
require
|
|
154
|
+
require "simplecov/railtie" if defined? Rails::Railtie
|
data/simplecov.gemspec
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require 'simplecov/version'
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
require "simplecov/version"
|
|
4
3
|
|
|
5
4
|
Gem::Specification.new do |gem|
|
|
6
|
-
gem.name =
|
|
5
|
+
gem.name = "simplecov"
|
|
7
6
|
gem.version = SimpleCov::VERSION
|
|
8
7
|
gem.platform = Gem::Platform::RUBY
|
|
9
8
|
gem.authors = ["Christoph Olszowka"]
|
|
10
|
-
gem.email = [
|
|
11
|
-
gem.homepage =
|
|
12
|
-
gem.description = %
|
|
9
|
+
gem.email = ["christoph at olszowka de"]
|
|
10
|
+
gem.homepage = "http://github.com/colszowka/simplecov"
|
|
11
|
+
gem.description = %(Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites)
|
|
13
12
|
gem.summary = gem.description
|
|
14
13
|
gem.license = "MIT"
|
|
15
14
|
|
|
16
|
-
gem.
|
|
17
|
-
|
|
18
|
-
gem.add_dependency
|
|
15
|
+
gem.required_ruby_version = ">= 1.8.7"
|
|
16
|
+
|
|
17
|
+
gem.add_dependency "json", "~> 1.8"
|
|
18
|
+
gem.add_dependency "simplecov-html", "~> 0.10.0"
|
|
19
|
+
gem.add_dependency "docile", "~> 1.1.0"
|
|
20
|
+
|
|
21
|
+
gem.add_development_dependency "bundler", "~> 1.9"
|
|
19
22
|
|
|
20
23
|
gem.files = `git ls-files`.split("\n")
|
|
21
24
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
22
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
23
|
-
gem.require_paths = [
|
|
25
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
26
|
+
gem.require_paths = ["lib"]
|
|
24
27
|
end
|
data/test/faked_project/Gemfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
gem
|
|
4
|
-
gem
|
|
5
|
-
gem
|
|
6
|
-
gem
|
|
3
|
+
gem "simplecov", :path => "../../../"
|
|
4
|
+
gem "rake"
|
|
5
|
+
gem "rspec", ">= 2.6.0"
|
|
6
|
+
gem "cucumber"
|
data/test/faked_project/Rakefile
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "bundler"
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rake/testtask"
|
|
4
4
|
Rake::TestTask.new(:test) do |test|
|
|
5
|
-
test.libs <<
|
|
6
|
-
test.test_files = FileList[
|
|
5
|
+
test.libs << "lib" << "test"
|
|
6
|
+
test.test_files = FileList["test/**/*_test.rb"].sort
|
|
7
7
|
test.verbose = true
|
|
8
8
|
end
|
|
@@ -7,7 +7,7 @@ When /^I write my cukes for the fake project$/ do
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
Then /^I make all neccessary tests in a single step$/ do
|
|
10
|
-
expect(FakedProject.foo).to eq(
|
|
10
|
+
expect(FakedProject.foo).to eq("bar")
|
|
11
11
|
|
|
12
12
|
expect(FrameworkSpecific.cucumber).to eq("Only tested in Cucumber")
|
|
13
13
|
|
|
@@ -17,7 +17,6 @@ Then /^I make all neccessary tests in a single step$/ do
|
|
|
17
17
|
expect(FakedProject.new.dynamic).to eq("A dynamically defined instance method")
|
|
18
18
|
|
|
19
19
|
something = SomeClass.new("foo")
|
|
20
|
-
expect(something.reverse).to eq(
|
|
21
|
-
expect(something.compare_with(
|
|
20
|
+
expect(something.reverse).to eq("oof")
|
|
21
|
+
expect(something.compare_with("foo")).to be true
|
|
22
22
|
end
|
|
23
|
-
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "bundler/setup"
|
|
2
2
|
|
|
3
3
|
# We're injecting simplecov_config via aruba in cucumber here
|
|
4
4
|
# depending on what the test case is...
|
|
5
5
|
begin
|
|
6
|
-
require File.join(File.dirname(__FILE__),
|
|
7
|
-
rescue LoadError
|
|
6
|
+
require File.join(File.dirname(__FILE__), "simplecov_config")
|
|
7
|
+
rescue LoadError
|
|
8
8
|
$stderr.puts "No SimpleCov config file found!"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
12
|
-
require
|
|
11
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/../../lib"))
|
|
12
|
+
require "faked_project"
|
|
@@ -14,14 +14,13 @@ class SomeClass
|
|
|
14
14
|
if item == label
|
|
15
15
|
return true
|
|
16
16
|
else
|
|
17
|
-
|
|
17
|
+
fail "Item does not match label"
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
rescue => err
|
|
19
|
+
rescue
|
|
21
20
|
false
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
private
|
|
25
24
|
|
|
26
25
|
def uncovered
|
|
27
26
|
"private method"
|
|
@@ -4,7 +4,7 @@ class FakedProject
|
|
|
4
4
|
end
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
Dir[File.join(File.dirname(__FILE__),
|
|
7
|
+
Dir[File.join(File.dirname(__FILE__), "faked_project/*.rb")].each do |file|
|
|
8
8
|
require file # Require all source files in project dynamically so we can inject some stuff depending on test situation
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe SomeClass do
|
|
4
4
|
subject { SomeClass.new("foo") }
|
|
5
5
|
|
|
6
6
|
it "should be reversible" do
|
|
7
|
-
expect(subject.reverse).to eq(
|
|
7
|
+
expect(subject.reverse).to eq("oof")
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "should compare with 'foo'" do
|
|
11
|
-
expect(subject.compare_with(
|
|
11
|
+
expect(subject.compare_with("foo")).to be true
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "bundler/setup"
|
|
2
2
|
|
|
3
3
|
# We're injecting simplecov_config via aruba in cucumber here
|
|
4
4
|
# depending on what the test case is...
|
|
5
5
|
begin
|
|
6
|
-
require File.join(File.dirname(__FILE__),
|
|
7
|
-
rescue LoadError
|
|
6
|
+
require File.join(File.dirname(__FILE__), "simplecov_config")
|
|
7
|
+
rescue LoadError
|
|
8
8
|
$stderr.puts "No SimpleCov config file found!"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
require
|
|
12
|
-
|
|
13
|
-
RSpec.configure do |config|
|
|
14
|
-
# some (optional) config here
|
|
15
|
-
end
|
|
11
|
+
require "faked_project"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "test_helper"
|
|
2
2
|
|
|
3
3
|
class SomeClassTest < Test::Unit::TestCase
|
|
4
4
|
def setup
|
|
@@ -6,10 +6,10 @@ class SomeClassTest < Test::Unit::TestCase
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def test_reverse
|
|
9
|
-
assert_equal
|
|
9
|
+
assert_equal "oof", @instance.reverse
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def test_comparison
|
|
13
|
-
assert @instance.compare_with(
|
|
13
|
+
assert @instance.compare_with("foo")
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "bundler/setup"
|
|
2
2
|
|
|
3
3
|
# We're injecting simplecov_config via aruba in cucumber here
|
|
4
4
|
# depending on what the test case is...
|
|
5
5
|
begin
|
|
6
|
-
require File.join(File.dirname(__FILE__),
|
|
7
|
-
rescue LoadError
|
|
6
|
+
require File.join(File.dirname(__FILE__), "simplecov_config")
|
|
7
|
+
rescue LoadError
|
|
8
8
|
$stderr.puts "No SimpleCov config file found!"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
require
|
|
12
|
-
|
|
13
|
-
require 'test/unit'
|
|
14
|
-
|
|
15
|
-
class Test::Unit::TestCase
|
|
16
|
-
end
|
|
11
|
+
require "faked_project"
|
|
12
|
+
require "test/unit"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
2
|
-
require
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", ".."))
|
|
2
|
+
require "lib/simplecov"
|
|
3
3
|
SimpleCov.start { command_name "Test" }
|
|
4
4
|
|
|
5
5
|
dir = File.expand_path(File.dirname(__FILE__))
|
|
@@ -12,4 +12,4 @@ code = %{
|
|
|
12
12
|
File.open(file, "w") { |f| f.print code }
|
|
13
13
|
load file
|
|
14
14
|
File.unlink file
|
|
15
|
-
|
|
15
|
+
fail unless kill_the_buddha(3) == 27
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
2
|
-
require
|
|
3
|
-
require
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
|
2
|
+
require "lib/simplecov"
|
|
3
|
+
require "rspec"
|
|
4
4
|
SimpleCov.start
|
|
5
|
-
describe
|
|
5
|
+
describe "exit status" do
|
|
6
6
|
it "should exit with a non-zero exit status when assertion fails" do
|
|
7
7
|
expect(1).to eq(2)
|
|
8
8
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
2
|
-
require
|
|
3
|
-
require
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
|
2
|
+
require "lib/simplecov"
|
|
3
|
+
require "rspec"
|
|
4
4
|
SimpleCov.start
|
|
5
|
-
describe
|
|
5
|
+
describe "exit status" do
|
|
6
6
|
it "should exit with a zero exit status when assertion fails" do
|
|
7
7
|
expect(1).to eq(1)
|
|
8
8
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
2
|
-
require
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
|
2
|
+
require "lib/simplecov"
|
|
3
3
|
SimpleCov.start
|
|
4
|
-
require
|
|
4
|
+
require "test/unit"
|
|
5
5
|
class FooTest < Test::Unit::TestCase
|
|
6
6
|
def test_foo
|
|
7
7
|
assert false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
2
|
-
require
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
|
2
|
+
require "lib/simplecov"
|
|
3
3
|
SimpleCov.start
|
|
4
|
-
require
|
|
4
|
+
require "test/unit"
|
|
5
5
|
class FooTest < Test::Unit::TestCase
|
|
6
6
|
def test_foo
|
|
7
7
|
assert true
|
data/test/fixtures/resultset2.rb
CHANGED