rcov_plugin 3.0.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.
- data/README.md +85 -0
- data/lib/rcov_plugin.rb +3 -0
- data/lib/rcov_plugin/railtie.rb +13 -0
- data/lib/rcov_plugin/version.rb +3 -0
- data/lib/tasks/rcov.rake +77 -0
- metadata +97 -0
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
rcov_plugin
|
2
|
+
===========
|
3
|
+
|
4
|
+
This is a simple rails plugin for Rails 3 that adds some useful rcov rake tasks.
|
5
|
+
|
6
|
+
rake test:coverage # Tests coverage on the entire application
|
7
|
+
rake test:coverage:units # Tests coverage for unit tests
|
8
|
+
rake test:coverage:functionals # Tests coverage for functional tests
|
9
|
+
rake test:coverage:integration # Tests coverage for integration tests
|
10
|
+
|
11
|
+
The task ends up creating a coverage folder with an html coverage report in it.
|
12
|
+
|
13
|
+
SHOW_ONLY is a comma-separated list of the files you'd like to see (although
|
14
|
+
you can only run functionals, you still see all the models and helpers which
|
15
|
+
are 'touched'). Right now there are four types of files rake test:coverage
|
16
|
+
recognizes: models, helpers, controllers, and lib. These can be abbreviated
|
17
|
+
to their first letters:
|
18
|
+
|
19
|
+
rake test:coverage SHOW_ONLY=models
|
20
|
+
rake test:coverage SHOW_ONLY=helpers,controllers
|
21
|
+
rake test:coverage SHOW_ONLY=h,c
|
22
|
+
|
23
|
+
Installing
|
24
|
+
=============
|
25
|
+
As of Rails 3, rake tasks can be distributed easily in plugins packaged as gems, and that's what we do here. So, to install rcov_plugin, simply do:
|
26
|
+
|
27
|
+
gem install rcov_plugin
|
28
|
+
|
29
|
+
or add the gem to your bundler Gemspec
|
30
|
+
|
31
|
+
gem "rcov_plugin"
|
32
|
+
|
33
|
+
JRuby Support
|
34
|
+
=============
|
35
|
+
rcov_plugin works great with JRuby.
|
36
|
+
|
37
|
+
If using JRuby, remember to run rake with it, like this:
|
38
|
+
jruby -S rake test:coverage
|
39
|
+
|
40
|
+
Special thanks go to Leonard Borges ([http://www.leonardoborges.com](http://www.leonardoborges.com)) for getting the plugin working with JRuby.
|
41
|
+
|
42
|
+
Requirements
|
43
|
+
============
|
44
|
+
|
45
|
+
This plugin requires rails 3 and
|
46
|
+
|
47
|
+
Using With Rails 2
|
48
|
+
============
|
49
|
+
This plugin worked with Rails 2 back in the day, and I've got a tag on the repo that you can use to install the old Rails 2 version. Use the following command:
|
50
|
+
|
51
|
+
script/plugin install -r rails_2 git://github.com/commondream/rcov_plugin.git
|
52
|
+
|
53
|
+
Contributors
|
54
|
+
============
|
55
|
+
Special thanks go to all of the contributors to this plugin:
|
56
|
+
|
57
|
+
* leonardoborges
|
58
|
+
* dovadi
|
59
|
+
* baldowl
|
60
|
+
* archfear
|
61
|
+
* nragaz
|
62
|
+
|
63
|
+
License
|
64
|
+
=======
|
65
|
+
Copyright (c) 2008 Alan Johnson
|
66
|
+
|
67
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
68
|
+
a copy of this software and associated documentation files (the
|
69
|
+
"Software"), to deal in the Software without restriction, including
|
70
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
71
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
72
|
+
permit persons to whom the Software is furnished to do so, subject to
|
73
|
+
the following conditions:
|
74
|
+
|
75
|
+
The above copyright notice and this permission notice shall be
|
76
|
+
included in all copies or substantial portions of the Software.
|
77
|
+
|
78
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
79
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
80
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
81
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
82
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
83
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
84
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
85
|
+
|
data/lib/rcov_plugin.rb
ADDED
data/lib/tasks/rcov.rake
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
def run_coverage(files)
|
2
|
+
rm_f "coverage"
|
3
|
+
rm_f "coverage.data"
|
4
|
+
|
5
|
+
# turn the files we want to run into a string
|
6
|
+
if files.empty?
|
7
|
+
puts "No files were specified for testing"
|
8
|
+
return
|
9
|
+
end
|
10
|
+
|
11
|
+
files = files.join(" ")
|
12
|
+
|
13
|
+
if RUBY_PLATFORM =~ /darwin/
|
14
|
+
exclude = '--exclude "gems/*" --exclude "Library/Frameworks/*"'
|
15
|
+
elsif RUBY_PLATFORM =~ /java/
|
16
|
+
exclude = '--exclude "rubygems/*,jruby/*,parser*,gemspec*,_DELEGATION*,eval*,recognize_optimized*,yaml,yaml/*,fcntl"'
|
17
|
+
else
|
18
|
+
exclude = '--exclude "rubygems/*"'
|
19
|
+
end
|
20
|
+
# rake test:units:rcov SHOW_ONLY=models,controllers,lib,helpers
|
21
|
+
# rake test:units:rcov SHOW_ONLY=m,c,l,h
|
22
|
+
if ENV['SHOW_ONLY']
|
23
|
+
params = String.new
|
24
|
+
show_only = ENV['SHOW_ONLY'].to_s.split(',').map{|x|x.strip}
|
25
|
+
if show_only.any?
|
26
|
+
reg_exp = []
|
27
|
+
for show_type in show_only
|
28
|
+
reg_exp << case show_type
|
29
|
+
when 'm', 'models' then 'app\/models'
|
30
|
+
when 'c', 'controllers' then 'app\/controllers'
|
31
|
+
when 'h', 'helpers' then 'app\/helpers'
|
32
|
+
when 'l', 'lib' then 'lib'
|
33
|
+
else
|
34
|
+
show_type
|
35
|
+
end
|
36
|
+
end
|
37
|
+
reg_exp.map!{ |m| "(#{m})" }
|
38
|
+
params << " --exclude \"^(?!#{reg_exp.join('|')})\""
|
39
|
+
end
|
40
|
+
exclude = exclude + params
|
41
|
+
end
|
42
|
+
|
43
|
+
rcov_bin = RUBY_PLATFORM =~ /java/ ? "jruby -S bundle exec rcov" : "bundle exec rcov"
|
44
|
+
rcov = "#{rcov_bin} --rails -Ilib:test --sort coverage --text-report #{exclude}"
|
45
|
+
puts
|
46
|
+
puts
|
47
|
+
puts "Running tests..."
|
48
|
+
cmd = "#{rcov} #{files}"
|
49
|
+
puts cmd
|
50
|
+
sh cmd
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace :test do
|
54
|
+
|
55
|
+
desc "Measures unit, functional, and integration test coverage"
|
56
|
+
task :coverage do
|
57
|
+
run_coverage Dir["test/unit/**/*.rb", "test/functional/**/*.rb", "test/integration/**/*.rb"]
|
58
|
+
end
|
59
|
+
|
60
|
+
namespace :coverage do
|
61
|
+
desc "Runs coverage on unit tests"
|
62
|
+
task :units do
|
63
|
+
run_coverage Dir["test/unit/**/*.rb"]
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Runs coverage on functional tests"
|
67
|
+
task :functionals do
|
68
|
+
run_coverage Dir["test/functional/**/*.rb"]
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Runs coverage on integration tests"
|
72
|
+
task :integration do
|
73
|
+
run_coverage Dir["test/integration/**/*.rb"]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rcov_plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 3
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 3.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Alan Johnson
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-16 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 3
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
- beta2
|
32
|
+
version: 3.0.0.beta2
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rcov
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 9
|
45
|
+
- 6
|
46
|
+
version: 0.9.6
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: rcov_plugin adds the rake tasks that you need to measure coverage in your Rails project
|
50
|
+
email:
|
51
|
+
- alan@commondream.net
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- lib/rcov_plugin/railtie.rb
|
60
|
+
- lib/rcov_plugin/version.rb
|
61
|
+
- lib/rcov_plugin.rb
|
62
|
+
- lib/tasks/rcov.rake
|
63
|
+
- README.md
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://github.com/commondream/rcov_plugin
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 1
|
86
|
+
- 3
|
87
|
+
- 6
|
88
|
+
version: 1.3.6
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.3.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: The easiest way to measure coverage for your Rails project
|
96
|
+
test_files: []
|
97
|
+
|