Created
October 15, 2011 08:01
-
-
Save nofxx/1289242 to your computer and use it in GitHub Desktop.
Finally working spec_helper spork/mongoid/fabrication/capybara
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 'pry' | |
require 'spork' | |
# Loading more in this block will cause your tests to run faster. | |
# if you change any configuration or code from libraries loaded | |
# need to restart spork for it take effect. | |
Spork.prefork do | |
ENV["RAILS_ENV"] ||= 'test' | |
require 'rails/application' | |
require 'rails/mongoid' | |
require 'capybara/rspec' | |
Spork.trap_class_method(Rails::Mongoid, :load_models) | |
Spork.trap_method(Rails::Application::RoutesReloader, :reload!) | |
# Capybara.javascript_driver = :webkit | |
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each {|f| require f} | |
require File.dirname(__FILE__) + "/../config/environment.rb" | |
#. After this line is too late. | |
require 'rspec/rails' | |
RSpec.configure do |config| | |
config.include HelperMethods | |
config.include Mongoid::Matchers | |
config.after(:each) do | |
Mongoid.database.collections.each do |collection| | |
unless collection.name =~ /^system\./ | |
collection.remove | |
end | |
end | |
end | |
config.mock_with :rspec | |
end | |
end | |
# Spork.each_run do | |
# #ActiveSupport::Dependencies.clear | |
# #Fabrication.clear_definitions | |
# #I18n.backend.reload! | |
# end if ENV['drb'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment