I am trying to speed up tests for a Rails application using an in-memory SQLite3 database as a test database for the application. I followed the instructions in this post.
My database configuration in database.yml as follows:
test: adapter: sqlite3 database: ":memory:" encoding: utf8 verbosity: quiet
I also created an initializer, as recommended:
def in_memory_database? Rails.env == "test" and ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLiteAdapter || ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter and Rails.configuration.database_configuration['test']['database'] == ':memory:' end if in_memory_database? ActiveRecord::Schema.verbose = false puts "creating sqlite in memory database" load "#{Rails.root}/db/schema.rb" end
All my tests fail because the devices cannot be loaded, as you can see:
creating sqlite in memory database Loaded suite test/unit/vendor_appliance_test Started E Finished in 0.070079 seconds. 1) Error: test_the_truth(VendorApplianceTest): ActiveRecord::StatementInvalid: Could not find table 'advertisers' 1 tests, 0 assertions, 0 failures, 1 errors
The initializer loads the database (as you can see from the first line of output), but for some reason the circuit is not visible in the tests because it does not look in the right place or because it was wiped by the time the tests started.
Has anyone seen this before?
source share