-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008 [name of plugin creator] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
Coveralls | ||
========= | ||
|
||
Introduction goes here. | ||
A rails plugin to make sure all files are required and show up in the code coverage report. (Untouched files are excluded and can thus inflate the overall code coverage.) If you forget to test a new library or module, it may not show up on the report, and thus you won't see that the coverage for that file is low. | ||
|
||
|
||
|
||
|
||
Example | ||
======= | ||
|
||
Example goes here. | ||
After installing the plugin create a test or spec that contains Coverall.require_all_ruby_files | ||
|
||
This will require all ruby files in /lib and /app if they haven't already been required. | ||
|
||
You can also pass in an array of directories to require. | ||
|
||
Coverall.require_all_ruby_files ["/app/models","/app/lib"] | ||
|
||
|
||
|
||
|
||
Thanks | ||
======= | ||
|
||
Special thanks go to Stephen Anderson for the name and for encouraging me to create this plugin. | ||
|
||
|
||
Copyright (c) 2008 Shawn Balestracci, released under the MIT license | ||
|
||
Copyright (c) 2008 [name of plugin creator], released under the MIT license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the coveralls plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the coveralls plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'Coveralls' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'coveralls' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Install hook code here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Coveralls | ||
# Method to require all ruby classes when calculating code coverage. | ||
# Call this to not leave untested files out of the code coverage percentages. | ||
def self.require_all_ruby_files(target_dirs=["/lib", "/app"]) | ||
Array(target_dirs).collect do |target_dir| | ||
dir = "#{RAILS_ROOT}#{target_dir}/**/*.rb" | ||
Dir.glob(dir).each do |ruby_file| | ||
obj = ruby_file.split("#{target_dir}/",2).last.split(".rb").first | ||
obj = obj.split("/",2).last if target_dir == "/app" | ||
begin | ||
# trigger the normal Rails mechanism to require files | ||
obj.classify.constantize | ||
rescue NameError, LoadError | ||
require obj | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# desc "Explaining what the task does" | ||
# task :coveralls do | ||
# # Task goes here | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'test/unit' | ||
ENV['RAILS_ENV'] = 'test' | ||
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..' | ||
require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb')) | ||
|
||
class CoverallsTest < Test::Unit::TestCase | ||
def test_default_require_all | ||
all_files = Coveralls.require_all_ruby_files | ||
controllers = (Dir.glob(File.join(RAILS_ROOT,"/app","controllers","**","*.rb"))) | ||
libs = (Dir.glob(File.join(RAILS_ROOT,"/lib","*.rb"))) | ||
|
||
assert_equal libs,all_files.flatten & libs | ||
assert_equal controllers,all_files.flatten & controllers | ||
end | ||
|
||
def test_invalid_require | ||
all_files = Coveralls.require_all_ruby_files "/dog_not_here_zzz" | ||
assert_equal [],all_files.flatten | ||
end | ||
|
||
def test_specify_directory | ||
all_files = Coveralls.require_all_ruby_files "/app/controllers" | ||
controllers = (Dir.glob(File.join(RAILS_ROOT,"/app","controllers","**","*.rb"))) | ||
|
||
assert_equal controllers, all_files.flatten | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Uninstall hook code here |