nulldb/nulldb — Issue #18: Testing without loading Rails
Author: arunsark
Created: 2012-01-05 19:28:55+00:00
State: open

I am using nulldb to test my Model.

But I am not loading Rails fully for testing models so that tests run real fast. I just load ActiveRecord and do the testing.

When I use nulldb like this

require_relative '../spec_helper_no_rails'
require_relative '../../app/models/branch'
require 'nulldb_rspec'

describe Branch, :nulldb => true do
include NullDB::RSpec::NullifiedDatabase
.....
end

All my tests run and they pass.
But in the end nulldb is trying to connect back to adapter test and that step is throwing error.
..gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': test database is not configured (ActiveRecord::AdapterNotSpecified)
from ..gems/1.9.1/bundler/gems/nulldb-fa3487a2eec3/lib/nulldb_rspec.rb:98:in `block in nullify_database'

Is it mandatory have Rails loaded for nulldb to work?

If I don't include NullDB::RSpec::NullifiedDatabase I am not getting the issue though. But I would like to include that.