spec/spec_helper.rb in timely-0.0.1 vs spec/spec_helper.rb in timely-0.0.2

- old
+ new

@@ -1,23 +1,46 @@ -begin - require 'spec' -rescue LoadError - require 'rubygems' - gem 'rspec' - require 'spec' -end +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# Require this file using `require "spec_helper.rb"` to ensure that it is only +# loaded once. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -# this is my favorite way to require ever -begin - require 'mocha' -rescue LoadError - require 'rubygems' - gem 'mocha' - require 'mocha' -end +require 'rubygems' +require 'bundler/setup' +require 'active_record' +require 'timely/rails' -Spec::Runner.configure do |config| - config.mock_with :mocha +if ENV['COVERAGE'] + require 'simplecov' + require 'simplecov-rcov' + SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter + 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 >= 50 + puts "Coverage must be above 50%. It is #{"%.2f" % percent}%" + Kernel.exit(1) + end + end end -$:.unshift(File.dirname(__FILE__) + '/../lib') require 'timely' + +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') + +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