* VRFS-1103 - coverage for all projects. need to figure out how to merge all

This commit is contained in:
Seth Call 2014-02-13 22:11:30 -06:00
parent 108a9564b6
commit 9e561c047a
10 changed files with 153 additions and 2 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
*.swp
HTML
.DS_Store
coverage/

46
admin/.simplecov Normal file
View File

@ -0,0 +1,46 @@
if ENV['COVERAGE'] == "1"
require 'simplecov-rcov'
class SimpleCov::Formatter::MergedFormatter
def format(result)
SimpleCov::Formatter::HTMLFormatter.new.format(result)
SimpleCov::Formatter::RcovFormatter.new.format(result)
end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
SimpleCov.start do
add_filter "/test/"
add_filter "/bin/"
add_filter "/scripts/"
add_filter "/tmp/"
add_filter "/vendor/"
add_filter "/spec/"
end
all_files = Dir['**/*.rb']
base_result = {}
all_files.each do |file|
absolute = File::expand_path(file)
lines = File.readlines(absolute, :encoding => 'UTF-8')
base_result[absolute] = lines.map do |l|
l.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')
l.encode!('UTF-8', 'UTF-16')
l.strip!
l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0
end
end
SimpleCov.at_exit do
coverage_result = Coverage.result
covered_files = coverage_result.keys
covered_files.each do |covered_file|
base_result.delete(covered_file)
end
merged = SimpleCov::Result.new(coverage_result).original_result.merge_resultset(base_result)
result = SimpleCov::Result.new(merged)
result.format!
end
end

View File

@ -108,3 +108,9 @@ group :development, :test do
gem 'database_cleaner', '0.7.0'
gem 'launchy'
end
group :test do
gem 'simplecov', '~> 0.7.1'
gem 'simplecov-rcov'
end

View File

@ -1,6 +1,5 @@
ENV["RAILS_ENV"] ||= 'test'
require 'simplecov'
# provision database
require 'active_record'

47
web/.simplecov Normal file
View File

@ -0,0 +1,47 @@
if ENV['COVERAGE'] == "1"
require 'simplecov-rcov'
class SimpleCov::Formatter::MergedFormatter
def format(result)
SimpleCov::Formatter::HTMLFormatter.new.format(result)
SimpleCov::Formatter::RcovFormatter.new.format(result)
end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
SimpleCov.start do
add_filter "/test/"
add_filter "/bin/"
add_filter "/scripts/"
add_filter "/tmp/"
add_filter "/vendor/"
add_filter "/spec/"
add_filter "/features/"
end
all_files = Dir['**/*.rb']
base_result = {}
all_files.each do |file|
absolute = File::expand_path(file)
lines = File.readlines(absolute, :encoding => 'UTF-8')
base_result[absolute] = lines.map do |l|
l.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')
l.encode!('UTF-8', 'UTF-16')
l.strip!
l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0
end
end
SimpleCov.at_exit do
coverage_result = Coverage.result
covered_files = coverage_result.keys
covered_files.each do |covered_file|
base_result.delete(covered_file)
end
merged = SimpleCov::Result.new(coverage_result).original_result.merge_resultset(base_result)
result = SimpleCov::Result.new(merged)
result.format!
end
end

View File

@ -93,6 +93,8 @@ group :assets do
end
group :test, :cucumber do
gem 'simplecov', '~> 0.7.1'
gem 'simplecov-rcov'
gem 'capybara'
#if ENV['JAMWEB_QT5'] == '1'
# # necessary on platforms such as arch linux, where pacman -S qt5-webkit is your easiet option

View File

@ -1,3 +1,4 @@
require 'simplecov'
require 'rubygems'
require 'spork'
require 'omniauth'

View File

@ -0,0 +1,46 @@
if ENV['COVERAGE'] == "1"
require 'simplecov-rcov'
class SimpleCov::Formatter::MergedFormatter
def format(result)
SimpleCov::Formatter::HTMLFormatter.new.format(result)
SimpleCov::Formatter::RcovFormatter.new.format(result)
end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
SimpleCov.start do
add_filter "/test/"
add_filter "/bin/"
add_filter "/scripts/"
add_filter "/tmp/"
add_filter "/vendor/"
add_filter "/spec/"
end
all_files = Dir['**/*.rb']
base_result = {}
all_files.each do |file|
absolute = File::expand_path(file)
lines = File.readlines(absolute, :encoding => 'UTF-8')
base_result[absolute] = lines.map do |l|
l.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')
l.encode!('UTF-8', 'UTF-16')
l.strip!
l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0
end
end
SimpleCov.at_exit do
coverage_result = Coverage.result
covered_files = coverage_result.keys
covered_files.each do |covered_file|
base_result.delete(covered_file)
end
merged = SimpleCov::Result.new(coverage_result).original_result.merge_resultset(base_result)
result = SimpleCov::Result.new(merged)
result.format!
end
end

View File

@ -49,6 +49,8 @@ group :development do
end
group :test do
gem 'simplecov', '~> 0.7.1'
gem 'simplecov-rcov'
gem 'cucumber'
gem 'rspec'
gem 'factory_girl'

View File

@ -1,3 +1,4 @@
require 'simplecov'
require 'active_record'
require 'jam_db'
require 'spec_db'