Skip to content

Instantly share code, notes, and snippets.

@jeffdeville
Created September 19, 2011 02:06
Show Gist options
  • Select an option

  • Save jeffdeville/1225863 to your computer and use it in GitHub Desktop.

Select an option

Save jeffdeville/1225863 to your computer and use it in GitHub Desktop.
Struggling with spork and rails 3.1
require 'rubygems'
require 'spork'
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 'stub_chain_mocha'
require 'rspec/rails'
require 'vcr_setup'
require 'rspec/given'
require 'rails/mongoid'
RSpec.configure do |config|
config.mock_with :mocha
config.after :suite do
delete_all
end
config.extend VCR::RSpec::Macros
end
def delete_all
db = Mongo::Connection.new.db("personalizr_test")
db.collections.select do |collection|
collection.name !~ /system/
end.each do |coll|
coll.drop
end
end
end
Spork.each_run do
# This code will be run each time you run your specs.
load "#{Rails.root}/config/routes.rb"
Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
Dir["#{Rails.root}/lib/**/*.rb"].each { |f| load f }
#load File.expand_path("../factories/factories", __FILE__)
require 'factory_girl_rails'
unless FactoryGirl.factories.blank? # first init will load factories, this should only run on subsequent reloads
FactoryGirl.factories.clear
FactoryGirl.find_definitions
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment