I just did a test where I ran one spec and deep deep within the code
under test, I printed out the DB connection of the AR class of a given
object, like so:
puts invoice.class.connection.inspect
My spec requires spec_helper.rb, which supposedly sets the Rails
environment to be “test”.
However, the output of that inspect looks like this:
.#<ActiveRecord::ConnectionAdapters::MysqlAdapter:0x46625e8
@last_verification=1
223509519, @logger=#<ActiveSupport::BufferedLogger:0x3590008 @buffer=[],
@no_blo
ck=false, @level=0, @auto_flushing=1,
@log=#<File:X:/log/development.log>>, @run
time=0.0, @quoted_table_names={“draft_invoices”=>"draft_invoices
"},
@connectio
n=#, @quoted_column_names={“draft_invoices”=>"draft_invoices
"},
@query_
cache_enabled=false, @config={:password=>“blah”, :username=>“root”,
:adapt
er=>“mysql”, :database=>“my_db_development”, :encoding=>“utf8”,
:host=>“mach
ost”, :allow_concurrency=>false}, @connection_options=[“machost”,
“root”, “r3n&s
t1mpy”, “aafes_vss_development”, nil, nil]>
Notice
@config={:password=>“blah”, :username=>“root”, :adapt
er=>“mysql”, :database=>“my_db_development”, :encoding=>“utf8”,
:host=>“mach
ost”, :allow_concurrency=>false}
which shows that I am hitting my development database. Why would I see
this output when running a spec that AFAIK, should be running against
the test DB?
Thanks,
wes