2011-11-20 10:39:46 +00:00
|
|
|
ENV["RAILS_ENV"] ||= 'test'
|
2011-08-14 19:16:59 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
require 'rails/mongoid'
|
|
|
|
require File.join(File.dirname(__FILE__), 'dummy', 'config', 'environment.rb')
|
|
|
|
require 'rspec/rails'
|
|
|
|
require 'factory_girl'
|
2011-08-14 19:16:59 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
|
|
# in spec/support/ and its subdirectories.
|
2011-11-20 11:25:01 +00:00
|
|
|
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
Locomotive.configure_for_test
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
RSpec.configure do |config|
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
config.include(Locomotive::RSpec::Matchers)
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
config.mock_with :mocha
|
2011-04-28 21:47:01 +00:00
|
|
|
|
2011-11-25 12:59:44 +00:00
|
|
|
config.before(:suite) do
|
|
|
|
Locomotive.configure_for_test(true)
|
|
|
|
end
|
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
config.before(:each) do
|
|
|
|
Locomotive.config.heroku = false
|
|
|
|
end
|
2010-07-30 21:04:18 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
require 'database_cleaner'
|
|
|
|
config.before(:suite) do
|
|
|
|
DatabaseCleaner.strategy = :truncation
|
|
|
|
DatabaseCleaner.orm = 'mongoid'
|
|
|
|
end
|
2010-12-14 17:00:12 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
config.before(:each) do
|
|
|
|
if self.described_class != Locomotive::Import::Job
|
|
|
|
DatabaseCleaner.clean
|
2010-10-28 23:36:45 +00:00
|
|
|
end
|
2011-11-20 10:39:46 +00:00
|
|
|
end
|
2011-08-13 23:24:02 +00:00
|
|
|
|
2011-11-20 10:39:46 +00:00
|
|
|
config.before(:all) do
|
|
|
|
if self.described_class == Locomotive::Import::Job
|
|
|
|
DatabaseCleaner.clean
|
2011-08-13 23:24:02 +00:00
|
|
|
end
|
|
|
|
end
|
2010-04-09 09:23:41 +00:00
|
|
|
end
|