title: In-Memory Sqlite DB in Rails with Rspec
body: <p>I have a Rails 4 application that I'm attempting to test in rspec using an in-memory sqlite database. When I run <code>rake</code> it tells me </p>
  
  <p><code>
  You have 66 pending migrations. Run `rake db:migrate` to update your database then try again.
  </code></p>
  
  <p><strong>spec_helper.rb</strong></p>
  
  <pre><code>ENV["RAILS_ENV"] ||= 'test'
  
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'capybara/rails'
  require 'capybara/rspec'
  require 'rspec/autorun'
  require 'capybara/poltergeist'
  require 'faker'
  require 'rake'
  
  load_schema = lambda {
    load "#{Rails.root.to_s}/db/schema.rb"
  }
  
  load_schema[]
  
  ...
  </code></pre>
  
  <p>Why am I getting this error? Why do I need to run migrations when I'm simply loading the schema file? What is the correct way to test using a sqlite in-memory db?</p>
  
  <p><strong>Update</strong></p>
  
  <p>When running <code>rake -t</code> It appears that rake is attempting to run the migrations</p>
  
  <pre><code>** Invoke default (first_time)
  ** Invoke spec (first_time)
  ** Invoke test:prepare (first_time)
  ** Invoke db:test:prepare (first_time)
  ** Invoke db:load_config (first_time)
  ** Execute db:load_config
  ** Execute db:test:prepare
  ** Invoke db:test:load (first_time)
  ** Invoke db:test:purge (first_time)
  ** Invoke environment (first_time)
  ** Execute environment
  ** Invoke db:load_config
  ** Execute db:test:purge
  ** Execute db:test:load
  ** Invoke db:test:load_schema (first_time)
  ** Invoke db:test:purge
  ** Execute db:test:load_schema
  ** Invoke db:schema:load (first_time)
  ** Invoke environment
  ** Invoke db:load_config
  ** Execute db:schema:load
  ** Invoke db:test:load
  ** Invoke db:abort_if_pending_migrations (first_time)
  ** Invoke environment
  ** Execute db:abort_if_pending_migrations
  </code></pre>
  
  <p>I don't need to run migrations. Is it possible to override this seemingly default behavior.</p>