add coverage report, set COVERAGE=1 in env when running specs

This commit is contained in:
wvengen 2013-07-25 13:59:55 +02:00
parent 7c65995b62
commit ca50006235
4 changed files with 21 additions and 0 deletions

View file

@ -76,6 +76,7 @@ group :development, :test do
gem 'capybara' gem 'capybara'
# webkit and poltergeist don't seem to work yet # webkit and poltergeist don't seem to work yet
gem 'database_cleaner' gem 'database_cleaner'
gem 'simplecov', require: false
end end
# Gems left for backwards compatibility # Gems left for backwards compatibility

View file

@ -251,6 +251,10 @@ GEM
simple_form (2.1.0) simple_form (2.1.0)
actionpack (~> 3.0) actionpack (~> 3.0)
activemodel (~> 3.0) activemodel (~> 3.0)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
sinatra (1.3.6) sinatra (1.3.6)
rack (~> 1.4) rack (~> 1.4)
rack-protection (~> 1.3) rack-protection (~> 1.3)
@ -339,6 +343,7 @@ DEPENDENCIES
simple-navigation simple-navigation
simple-navigation-bootstrap simple-navigation-bootstrap
simple_form simple_form
simplecov
sqlite3 sqlite3
therubyracer therubyracer
thin thin

View file

@ -1,5 +1,6 @@
# This file is copied to spec/ when you run 'rails generate rspec:install' # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test' ENV["RAILS_ENV"] ||= 'test'
require 'support/coverage' # needs to be first
require File.expand_path("../../config/environment", __FILE__) require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'rspec/autorun' require 'rspec/autorun'

14
spec/support/coverage.rb Normal file
View file

@ -0,0 +1,14 @@
# optional test coverage
# needs to be loaded first, e.g. add a require at top of spec_helper
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter '/spec/'
add_filter '/test/'
add_group 'Models', '/app/models/'
add_group 'Controllers', '/app/controllers/'
add_group 'Helpers', '/app/helpers/'
add_group 'Documents', '/app/documents/'
add_group 'Libraries', '/lib/'
end
end