Optimize execution duration for rspec specs

* Use in memory sqlite database for test environment
* Monkey patch BCrypt default cost factor
* Clean spec/spec_helper.rb
This commit is contained in:
Thibault Jouan
2011-08-31 10:53:49 +00:00
parent 47b4f7ac83
commit 7187266982
4 changed files with 17 additions and 18 deletions

View File

@@ -1,27 +1,16 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
ENV['RAILS_ENV'] ||= 'test'
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}
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"
# 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
load "#{Rails.root.to_s}/db/schema.rb"

View File

@@ -0,0 +1,8 @@
module BCrypt
class Engine
[:DEFAULT_COST, :MIN_COST].each do |sym|
remove_const sym
const_set sym, 1
end
end
end