# Notice there is a .rspec file in the root folder. It defines rspec arguments # Ruby 1.9 uses simplecov. The ENV['COVERAGE'] is set when rake coverage is run in ruby 1.9 if ENV['COVERAGE'] require 'simplecov' SimpleCov.start do # Remove the spec folder from coverage. By default all code files are included. For more config options see # https://github.com/colszowka/simplecov add_filter File.expand_path('../../spec',__FILE__) end end # Modify load path so you can require 'multi_config' directly. $LOAD_PATH.unshift(File.expand_path('../../lib',__FILE__)) require 'rubygems' # Loads bundler setup tasks. Now if I run spec without installing gems then it would say gem not installed and # do bundle install instead of ugly load error on require. require 'bundler/setup' # This will require me all the gems automatically for the groups. If I do only .setup then I will have to require gems # manually. Note that you have still have to require some gems if they are part of bigger gem like ActiveRecord which is # part of Rails. You can say :require => false in gemfile to always use explicit requiring Bundler.require(:default, :test) require 'active_record' require 'multi_config/orms/active_record' # This is required to rcov to run. Otherwise it runs without specs require 'rspec/autorun' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f} # Set Rails environment as test ENV['RAILS_ENV'] = 'test' # 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"` to ensure that it is only # loaded once. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = 'random' # Setting rails default settings such as Rails.root before every spec config.before(:each) do set_rails_conf end end