Skip to content

Instantly share code, notes, and snippets.

@nicholaides
Created March 17, 2011 19:56
Show Gist options
  • Save nicholaides/875006 to your computer and use it in GitHub Desktop.
Save nicholaides/875006 to your computer and use it in GitHub Desktop.
Spec helper w/ Spork. Spork pre, Rails 3, Rspec 2
--color
--debug
--backtrace
--drb
gem 'spork', '>= 0.9.0.rc4'
# also, it says to just use factory girl
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require "rails/mongoid"
Spork.trap_class_method(Rails::Mongoid, :load_models)
require "rails/application"
Spork.trap_method(Rails::Application, :reload_routes!)
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# 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
end
end
Spork.each_run do
FactoryGirl.definition_file_paths = [
File.join(Rails.root, 'spec', 'factories')
]
FactoryGirl.find_definitions
end
#TODO: put this in another file.
class Numeric
def of
(0...self).map{|i| yield(i) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment