spec/spec_helper.rb in dependent_restrict-0.2.1 vs spec/spec_helper.rb in dependent_restrict-0.2.2

- old
+ new

@@ -6,23 +6,37 @@ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration require 'rubygems' require 'bundler/setup' +MINIMUM_COVERAGE = 81 + if ENV['COVERAGE'] require 'simplecov' - require 'simplecov-rcov' - SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter + require 'coveralls' + Coveralls.wear! + + SimpleCov.formatter = Coveralls::SimpleCov::Formatter SimpleCov.start do add_filter '/vendor/' add_filter '/spec/' add_group 'lib', 'lib' end + SimpleCov.at_exit do + SimpleCov.result.format! + percent = SimpleCov.result.covered_percent + unless percent >= MINIMUM_COVERAGE + puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{"%.2f" % percent}%" + Kernel.exit(1) + end + end end require 'dependent_restrict' -RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true - config.run_all_when_everything_filtered = true - config.filter_run :focus -end +DB_FILE = 'tmp/test_db' +FileUtils.mkdir_p File.dirname(DB_FILE) +FileUtils.rm_f DB_FILE + +ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE + +load 'spec/schema.rb'