Skip to content

Instantly share code, notes, and snippets.

@nofxx
Created October 15, 2011 08:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nofxx/1289242 to your computer and use it in GitHub Desktop.
Save nofxx/1289242 to your computer and use it in GitHub Desktop.
Finally working spec_helper spork/mongoid/fabrication/capybara
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