Created
February 28, 2012 03:36
-
-
Save victorhg/1929209 to your computer and use it in GitHub Desktop.
spec_helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
# 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/rails' | |
require 'rspec/autorun' | |
require 'capybara/rspec' | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
Dir[Rails.root.join("lib/*.rb")].each {|f| require f} | |
Spork.trap_method(Rails::Application::RoutesReloader, :reload!) | |
Capybara.javascript_driver = :webkit | |
RSpec.configure do |config| | |
config.infer_base_class_for_anonymous_controllers = false | |
config.include Devise::TestHelpers, :type => :controller | |
config.filter_run_excluding :js => true | |
# Clean up the database | |
require 'database_cleaner' | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.orm = "mongoid" | |
end | |
config.before(:each) do | |
DatabaseCleaner.clean | |
Mongoid::IdentityMap.clear | |
end | |
end | |
end | |
Spork.each_run do | |
Rails.application.reload_routes! | |
Fabrication.clear_definitions | |
# To avoid the following error when running the specs with spork: | |
# warning: toplevel constant AdminController referenced by | |
# Backoffice::AdminController | |
# the backoffice controllers must be loaded first to avoid global namespace | |
# controllers to pollute the namespace | |
# https://groups.google.com/forum/#!topic/sporkgem/VN_R6IWtU3M | |
Dir[File.expand_path("app/controllers/backoffice/*.rb")].each do |file| | |
require file | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment