From 022c733b6dd9ac76b02328d2bd63ad18f3408e46 Mon Sep 17 00:00:00 2001 From: James Mason Date: Thu, 8 May 2014 12:05:57 -0700 Subject: [PATCH 1/2] Suggest an in-memory db for testing. --- config/database.yml.example | 2 +- spec/spec_helper.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/database.yml.example b/config/database.yml.example index 51a4dd45..ba386c23 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -14,7 +14,7 @@ development: # Do not set this db to the same as development or production. test: adapter: sqlite3 - database: db/test.sqlite3 + database: ":memory:" pool: 5 timeout: 5000 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5b6b9b08..a045a215 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,11 @@ Coveralls.wear!('rails') # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) + +if Rails.configuration.database_configuration['test']['database'] == ':memory:' + load "#{Rails.root}/db/schema.rb" +end + require 'rspec/rails' # Requires supporting ruby files with custom matchers and macros, etc, in @@ -39,9 +44,9 @@ RSpec.configure do |config| # Include factory_girls syntax config.include FactoryGirl::Syntax::Methods - + # As we start from scratch in April 2014, let's forbid the old :should syntax config.expect_with :rspec do |c| c.syntax = :expect - end + end end From 3b84b57a020e5f816122e3217157a3aa41a7b8f0 Mon Sep 17 00:00:00 2001 From: James Mason Date: Thu, 8 May 2014 14:48:10 -0700 Subject: [PATCH 2/2] Seed the in-memory test db. --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a045a215..0df96be7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,6 +6,7 @@ require File.expand_path("../../config/environment", __FILE__) if Rails.configuration.database_configuration['test']['database'] == ':memory:' load "#{Rails.root}/db/schema.rb" + load "#{Rails.root}/db/seeds.rb" end require 'rspec/rails'