summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2014-04-26 17:02:27 -0400
committerAustin Ziegler <austin@zieglers.ca>2014-04-26 17:02:27 -0400
commit5a81927584dc5a715f17ed4d72b96bfac9a0f5e0 (patch)
tree9e5ef5891718ed72988468bcf3c7c2c8a69b998a /spec
parentc2479b3095a01620843d7986b5ed97903d47bae6 (diff)
downloaddiff-lcs-5a81927584dc5a715f17ed4d72b96bfac9a0f5e0.tar.gz
Enabling code coverage.
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a5ca00d..23d9a86 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,6 +2,43 @@
require 'rubygems'
require 'pathname'
+require 'psych'
+
+if ENV['COVERAGE']
+ require 'simplecov'
+
+ if ENV['COVERALLS']
+ require 'coveralls'
+ formatters = Coveralls::SimpleCov::Formatter
+ else
+ def try_require(resource, &block)
+ require resource
+ block.call
+ rescue LoadError
+ nil
+ end
+
+ formatters = [ SimpleCov::Formatter::HTMLFormatter ]
+
+ try_require('simplecov-rcov') { formatters << SimpleCov::Formatter::RcovFormatter }
+ try_require('simplecov-vim/formatter') {
+ formatters << SimpleCov::Formatter::VimFormatter
+ }
+ try_require('simplecov-sublime-ruby-coverage') {
+ formatters << SimpleCov::Formatter::SublimeRubyCoverageFormatter
+ }
+
+ formatters = if formatters.size == 1
+ formatters.first
+ else
+ SimpleCov::Formatter::MultiFormatter[*formatters]
+ end
+ end
+
+ SimpleCov.start do
+ formatter formatters
+ end
+end
file = Pathname.new(__FILE__).expand_path
path = file.parent