Skip to content

Instantly share code, notes, and snippets.

@davidmohara
Created September 7, 2011 20:32
Show Gist options
  • Save davidmohara/1201645 to your computer and use it in GitHub Desktop.
Save davidmohara/1201645 to your computer and use it in GitHub Desktop.
spec_helper.rb
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'
# Outputs the requires to see if they should be optimized
#module Kernel
#def require_with_trace(*args)
#start = Time.now.to_f
#@indent ||= 0
#@indent += 2
#require_without_trace(*args)
#@indent -= 2
#Kernel::puts "#{' '*@indent}#{((Time.now.to_f - start)*1000).to_i} #{args[0]}"
#end
#alias_method_chain :require, :trace
#end
ActiveSupport::Dependencies.clear
end
Spork.each_run do
# Clear the factories
FactoryGirl.factories.clear
# Reload the routes
Upkeepr::Application.reload_routes!
# 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}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# Devise specific pieces
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment