tests: make simplecov/coveralls optional
If we do not have SimpleCov or Coveralls installed, we should be able to continue with the rest of the test suite. This allows the tests to run outside of Bundler if SimpleCov or Coveralls are not installed.
This commit is contained in:
parent
47489ab34b
commit
33834852c7
|
@ -1,20 +1,24 @@
|
||||||
require 'simplecov'
|
begin
|
||||||
require 'coveralls'
|
require 'simplecov'
|
||||||
|
require 'coveralls'
|
||||||
|
|
||||||
# On Ruby 1.9+ use SimpleCov and publish to Coveralls.io
|
# On Ruby 1.9+ use SimpleCov and publish to Coveralls.io
|
||||||
if !RUBY_VERSION.start_with? '1.8'
|
if !RUBY_VERSION.start_with? '1.8'
|
||||||
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
||||||
SimpleCov::Formatter::HTMLFormatter,
|
SimpleCov::Formatter::HTMLFormatter,
|
||||||
Coveralls::SimpleCov::Formatter
|
Coveralls::SimpleCov::Formatter
|
||||||
]
|
]
|
||||||
SimpleCov.start do
|
SimpleCov.start do
|
||||||
add_filter '/spec/' # exclude test code
|
add_filter '/spec/' # exclude test code
|
||||||
add_filter '/vendor/' # exclude gems which are vendored on Travis CI
|
add_filter '/vendor/' # exclude gems which are vendored on Travis CI
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove Docile, which was required by SimpleCov, to require again later
|
||||||
|
Object.send(:remove_const, :Docile)
|
||||||
|
$LOADED_FEATURES.reject! { |f| f =~ /\/docile\// }
|
||||||
end
|
end
|
||||||
|
rescue LoadError
|
||||||
# Remove Docile, which was required by SimpleCov, to require again later
|
warn 'warning: simplecov/coveralls gems not found; skipping coverage'
|
||||||
Object.send(:remove_const, :Docile)
|
|
||||||
$LOADED_FEATURES.reject! { |f| f =~ /\/docile\// }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
lib_dir = File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
lib_dir = File.join(File.dirname(File.dirname(__FILE__)), 'lib')
|
||||||
|
@ -30,4 +34,4 @@ RSpec.configure do |config|
|
||||||
config.expect_with :rspec do |c|
|
config.expect_with :rspec do |c|
|
||||||
c.syntax = :expect
|
c.syntax = :expect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue