Forum: RSpec What makes specs run against the test database?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2008-10-09 03:50
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=#<Mysql>, @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
Nick H. (Guest)
on 2008-10-09 03:54
(Received via mailing list)
On 2008-10-08, at 19:50, Wes G. wrote:
>
> Thanks,
> wes


This sounds like a dumb question, but in database.yml , have you
confirmed that your test DB is configured for use in the test
environment?

Cheers,
Nick
Wes G. (Guest)
on 2008-10-09 04:14
(Received via mailing list)
Yes.
This topic is locked and can not be replied to.