simplecov 0.4.0 → 0.4.1
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.
- data/.gitignore +4 -0
- data/README.rdoc +16 -7
- data/lib/simplecov/result.rb +7 -2
- data/lib/simplecov/version.rb +1 -1
- data/simplecov.gemspec +1 -1
- data/test/fixtures/deleted_source_sample.rb +15 -0
- data/test/test_deleted_source.rb +16 -0
- metadata +9 -6
- data/Gemfile.lock +0 -32
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -15,16 +15,22 @@ automatically when you launch SimpleCov. If you're curious, you can find it at h
|
|
15
15
|
== Basic usage
|
16
16
|
|
17
17
|
Update your Gemfile with this and do a bundle install:
|
18
|
-
group :test do
|
19
|
-
gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
|
20
|
-
end
|
21
18
|
|
22
|
-
|
19
|
+
gem 'simplecov', '>= 0.4.0', :require => false, :group => :test
|
20
|
+
|
21
|
+
Then, add the following to your test/test_helper.rb (right at the top, line 00) or spec_helper.rb or cucumber env.rb or whatever
|
22
|
+
test framework you prefer, really - just make sure simplecov is loaded and started BEFORE your app code is loaded:
|
23
23
|
|
24
24
|
require 'simplecov'
|
25
|
-
SimpleCov.start
|
25
|
+
SimpleCov.start
|
26
|
+
|
27
|
+
Now, when running tests you'll get a coverage/ folder inside your app's root where you can browse your code coverage.
|
26
28
|
|
27
|
-
|
29
|
+
If you're making a Rails application, SimpleCov comes with a built-in adapter (see below for more information on what adapters are)
|
30
|
+
for it which will give you handy tabs in the output webpage for your Controllers, Views, Models, etc. To use it, the first two lines of your test_helper should be like this:
|
31
|
+
|
32
|
+
require 'simplecov'
|
33
|
+
SimpleCov.start 'rails'
|
28
34
|
|
29
35
|
== Example output
|
30
36
|
|
@@ -32,7 +38,7 @@ For the Devise Ruby gem (some tests were removed, they just have too awesome tes
|
|
32
38
|
|
33
39
|
http://img.skitch.com/20100823-n9f52i3ty3qa7cqj33rafghrtc.png
|
34
40
|
|
35
|
-
== Usage with Cucumber
|
41
|
+
== Usage with Cucumber, RSpec, (name your framework)
|
36
42
|
|
37
43
|
Similarily to the usage with Test::Unit described above, the only thing you have to do is to add the simplecov
|
38
44
|
config to the very top of your Cucumber/RSpec/whatever setup file.
|
@@ -42,6 +48,9 @@ Other test frameworks should work accordingly.
|
|
42
48
|
|
43
49
|
require 'simplecov'
|
44
50
|
SimpleCov.start 'rails'
|
51
|
+
|
52
|
+
You could even track what kind of code your UI testers are touching if you want to go overboard with things. SimpleCov does not
|
53
|
+
care what kind of framework it is running in, it just looks at what code is being executed and generates a report about it.
|
45
54
|
|
46
55
|
== Configuration
|
47
56
|
|
data/lib/simplecov/result.rb
CHANGED
@@ -21,7 +21,9 @@ module SimpleCov
|
|
21
21
|
# coverage data)
|
22
22
|
def initialize(original_result)
|
23
23
|
@original_result = original_result.freeze
|
24
|
-
@files = original_result.map {|filename, coverage|
|
24
|
+
@files = original_result.map {|filename, coverage|
|
25
|
+
SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)
|
26
|
+
}.compact.sort_by(&:filename)
|
25
27
|
filter!
|
26
28
|
end
|
27
29
|
|
@@ -48,7 +50,10 @@ module SimpleCov
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
51
|
-
|
53
|
+
|
54
|
+
total_lines = (missed_lines + covered_lines)
|
55
|
+
# Make sure that weird rounding error from #15, #23 and #24 does not occur again!
|
56
|
+
total_lines.zero? ? 0 : 100.0 * covered_lines / total_lines
|
52
57
|
end
|
53
58
|
|
54
59
|
# Applies the configured SimpleCov.formatter on this result
|
data/lib/simplecov/version.rb
CHANGED
data/simplecov.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = "simplecov"
|
16
16
|
|
17
|
-
s.add_dependency 'simplecov-html', "~> 0.4.
|
17
|
+
s.add_dependency 'simplecov-html', "~> 0.4.3"
|
18
18
|
s.add_development_dependency "shoulda", "2.10.3"
|
19
19
|
s.add_development_dependency "rspec", "~> 2.0.0"
|
20
20
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
|
2
|
+
require 'lib/simplecov'
|
3
|
+
SimpleCov.start
|
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
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
# Test to verify correct handling of deleted files,
|
4
|
+
# see issue #9 on github
|
5
|
+
class TestDeletedSource < Test::Unit::TestCase
|
6
|
+
on_ruby '1.8', '1.9' do
|
7
|
+
context "A source file which is subsequently deleted" do
|
8
|
+
should "not cause an error" do
|
9
|
+
Dir.chdir(File.join(File.dirname(__FILE__), 'fixtures')) do
|
10
|
+
`ruby deleted_source_sample.rb`
|
11
|
+
assert_equal 0, $?.exitstatus
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Christoph Olszowka
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-25 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,8 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 0
|
30
30
|
- 4
|
31
|
-
-
|
32
|
-
version: 0.4.
|
31
|
+
- 3
|
32
|
+
version: 0.4.3
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -76,7 +76,6 @@ files:
|
|
76
76
|
- .gitignore
|
77
77
|
- .rvmrc
|
78
78
|
- Gemfile
|
79
|
-
- Gemfile.lock
|
80
79
|
- LICENSE
|
81
80
|
- README.rdoc
|
82
81
|
- Rakefile
|
@@ -96,6 +95,7 @@ files:
|
|
96
95
|
- simplecov.gemspec
|
97
96
|
- test/fixtures/app/controllers/sample_controller.rb
|
98
97
|
- test/fixtures/app/models/user.rb
|
98
|
+
- test/fixtures/deleted_source_sample.rb
|
99
99
|
- test/fixtures/frameworks/rspec_bad.rb
|
100
100
|
- test/fixtures/frameworks/rspec_good.rb
|
101
101
|
- test/fixtures/frameworks/testunit_bad.rb
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- test/shoulda_macros.rb
|
108
108
|
- test/test_1_8_fallbacks.rb
|
109
109
|
- test/test_command_guesser.rb
|
110
|
+
- test/test_deleted_source.rb
|
110
111
|
- test/test_filters.rb
|
111
112
|
- test/test_merge_helpers.rb
|
112
113
|
- test/test_result.rb
|
@@ -148,6 +149,7 @@ summary: Code coverage for Ruby 1.9 with a powerful configuration library and au
|
|
148
149
|
test_files:
|
149
150
|
- test/fixtures/app/controllers/sample_controller.rb
|
150
151
|
- test/fixtures/app/models/user.rb
|
152
|
+
- test/fixtures/deleted_source_sample.rb
|
151
153
|
- test/fixtures/frameworks/rspec_bad.rb
|
152
154
|
- test/fixtures/frameworks/rspec_good.rb
|
153
155
|
- test/fixtures/frameworks/testunit_bad.rb
|
@@ -159,6 +161,7 @@ test_files:
|
|
159
161
|
- test/shoulda_macros.rb
|
160
162
|
- test/test_1_8_fallbacks.rb
|
161
163
|
- test/test_command_guesser.rb
|
164
|
+
- test/test_deleted_source.rb
|
162
165
|
- test/test_filters.rb
|
163
166
|
- test/test_merge_helpers.rb
|
164
167
|
- test/test_result.rb
|
data/Gemfile.lock
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
simplecov (0.4.0)
|
5
|
-
simplecov-html (~> 0.4.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
diff-lcs (1.1.2)
|
11
|
-
rspec (2.0.1)
|
12
|
-
rspec-core (~> 2.0.1)
|
13
|
-
rspec-expectations (~> 2.0.1)
|
14
|
-
rspec-mocks (~> 2.0.1)
|
15
|
-
rspec-core (2.0.1)
|
16
|
-
rspec-expectations (2.0.1)
|
17
|
-
diff-lcs (>= 1.1.2)
|
18
|
-
rspec-mocks (2.0.1)
|
19
|
-
rspec-core (~> 2.0.1)
|
20
|
-
rspec-expectations (~> 2.0.1)
|
21
|
-
shoulda (2.10.3)
|
22
|
-
simplecov-html (0.4.0)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
java
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
rspec (~> 2.0.0)
|
30
|
-
shoulda (= 2.10.3)
|
31
|
-
simplecov!
|
32
|
-
simplecov-html (~> 0.4.0)
|