2012-08-06 03:01:00 +00:00
require 'active_record'
require 'jam_db'
require 'spec_db'
2013-02-13 01:56:40 +00:00
require 'uses_temp_files'
2012-08-06 03:01:00 +00:00
# recreate test database and migrate it
SpecDb :: recreate_database
2012-10-21 01:55:49 +00:00
2012-08-06 03:01:00 +00:00
# initialize ActiveRecord's db connection
ActiveRecord :: Base . establish_connection ( YAML :: load ( File . open ( 'config/database.yml' ) ) [ " test " ] )
require 'jam_ruby'
require 'factory_girl'
require 'rubygems'
require 'spork'
require 'database_cleaner'
2012-08-18 18:48:43 +00:00
require 'factories'
2012-08-06 03:01:00 +00:00
include JamRuby
2013-03-15 04:22:31 +00:00
# manually register observers
ActiveRecord :: Base . add_observer InvitedUserObserver . instance
2013-05-10 12:10:33 +00:00
ActiveRecord :: Base . add_observer UserObserver . instance
2012-08-06 03:01:00 +00:00
2012-11-11 01:07:17 +00:00
# put ActionMailer into test mode
ActionMailer :: Base . delivery_method = :test
2013-02-13 01:56:40 +00:00
# set up carrierwave to use file (instead of say, fog) for testing
CarrierWave . configure do | config |
config . storage = :file
config . enable_processing = false
end
2012-08-06 03:01:00 +00:00
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork . prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
#ENV["RAILS_ENV"] ||= 'test'
#require File.expand_path("../../config/environment", __FILE__)
require 'rspec/autorun'
#require 'rspec/rails'
# 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
config . filter_run :focus
2013-06-24 21:31:40 +00:00
# you can mark a test as slow so that developers won't commonly hit it, but build server will http://blog.davidchelimsky.net/2010/06/14/filtering-examples-in-rspec-2/
2013-06-24 21:38:31 +00:00
config . filter_run_excluding slow : true unless ENV [ 'RUN_SLOW_TESTS' ] == " 1 "
2013-06-24 21:31:40 +00:00
2012-08-06 03:01:00 +00:00
config . before ( :suite ) do
2012-11-30 15:23:43 +00:00
DatabaseCleaner . strategy = :truncation , { :except = > %w[ instruments genres ] }
2012-11-12 12:55:03 +00:00
DatabaseCleaner . clean_with ( :truncation , { :except = > %w[ instruments genres ] } )
2012-08-06 03:01:00 +00:00
end
config . before ( :each ) do
DatabaseCleaner . start
end
config . after ( :each ) do
DatabaseCleaner . clean
end
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
#config.use_transactional_fixtures = 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'
end
end
Spork . each_run do
# This code will be run each time you run your specs.
2013-06-24 21:38:31 +00:00
end