[rspec-users] What makes specs run against the test database?

Wes Gamble lists at ruby-forum.com
Wed Oct 8 19:50:24 EDT 2008

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:

223509519, @logger=#<ActiveSupport::BufferedLogger:0x3590008 @buffer=[],
ck=false, @level=0, @auto_flushing=1,
@log=#<File:X:/log/development.log>>, @run
time=0.0, @quoted_table_names={"draft_invoices"=>"`draft_invoices`"},
n=#<Mysql>, @quoted_column_names={"draft_invoices"=>"`draft_invoices`"},
cache_enabled=false, @config={:password=>"blah", :username=>"root",
er=>"mysql", :database=>"my_db_development", :encoding=>"utf8",
ost", :allow_concurrency=>false}, @connection_options=["machost",
"root", "r3n&s
t1mpy", "aafes_vss_development", nil, nil]>


@config={:password=>"blah", :username=>"root", :adapt
er=>"mysql", :database=>"my_db_development", :encoding=>"utf8",
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?

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list