Wes Gamble
2008-Oct-08 23:50 UTC
[rspec-users] What makes specs run against the test database?
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
--
Posted via http://www.ruby-forum.com/.
Nick Hoffman
2008-Oct-08 23:54 UTC
[rspec-users] What makes specs run against the test database?
On 2008-10-08, at 19:50, Wes Gamble wrote:> 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: > > <..snip..> > > 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, > wesThis 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 Gamble
2008-Oct-09 00:10 UTC
[rspec-users] What makes specs run against the test database?
Yes. Nick Hoffman wrote:> On 2008-10-08, at 19:50, Wes Gamble wrote: >> 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: >> >> <..snip..> >> >> 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 > > > 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >