Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created June 11, 2012 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tomas-stefano/2911844 to your computer and use it in GitHub Desktop.
Save tomas-stefano/2911844 to your computer and use it in GitHub Desktop.
Fast Specs! Unit, model and integration tests
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'machinist/active_record'
require 'machinist/caching/active_record'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
spec_support = Rails.root.join("spec/support/**/*.rb")
blueprints = Rails.root.join('spec/blueprints/**/*.rb')
Dir[spec_support, blueprints].each { |f| require(f) }
HTTPI.log = false
Savon.log = false
RSpec.configure do |config|
config.include Rack::Test::Methods
config.include Helpers
config.include GatewayMatchers
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before do
DatabaseCleaner.start
Machinist::Caching::Shop.instance.reset!
end
config.after do
DatabaseCleaner.clean
end
end
require 'unit_test'
require "bundler/setup"
require 'active_support/i18n'
Bundler.require :models # Create a group in the Gemfile with :models in a group
I18n.load_path << Dir['config/locales/*.yml']
I18n.locale = 'pt-BR'
I18n.load_path.flatten!
database_yml = YAML.load_file(File.expand_path('config/database.yml'))
ActiveRecord::Base.establish_connection(database_yml['test'])
require 'active_support/dependencies'
%w(app/business app/enumerations app/models app/validators).each do |path|
ActiveSupport::Dependencies.autoload_paths.push(path) unless ActiveSupport::Dependencies.autoload_paths.include?(path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment