Skip to content

Instantly share code, notes, and snippets.

@Bivek
Created September 7, 2013 06:14
Show Gist options
  • Save Bivek/6473237 to your computer and use it in GitHub Desktop.
Save Bivek/6473237 to your computer and use it in GitHub Desktop.
# inspired by http://blog.leshill.org/blog/2011/10/23/fast-specs.html
# to get specs running without rails (faster) do
# SKIP_RAILS=yes time bundle exec rspec
# or
# SKIP_RAILS=yes time bundle exec guard
# spec_helper
ENV["RAILS_ENV"] ||= 'test'
ENV["SKIP_RAILS"] ||= 'no'
def if_fast_spec
if block_given? && ENV["SKIP_RAILS"] != 'no'
yield
end
end
if ENV["SKIP_RAILS"] == 'no'
require 'rails_spec_helper'
else
require 'fast_spec_helper'
end
# fast_spec_helper
require 'rspec'
def app_require(file)
require File.expand_path(file)
end
def support_require(file)
app_require("spec/support/#{file}.rb")
end
def fast_support_require(file)
require "fast_support/#{file}.rb"
end
# models/user_spec.rb
if_fast_spec do
fast_support_require 'database'
fast_support_require 'database_cleaner'
app_require 'app/models/user'
end
describe User do
it "does something
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment