[rspec-users] When is spec_helper.rb actually executed?

Greg Hauptmann greg.hauptmann.ruby at gmail.com
Thu Nov 6 05:33:39 EST 2008

can someone advise how best to handle the situation where I want to
keep (i.e. not have deleted) my configuration intact?
Perhaps seed it in environment/test.rb - but how do I get a normal
rails line of code to run in the "test.rb" file (i.e. only for when
starting up in test mode)?
I get "ActiveRecord::ConnectionNotEstablished" when I include
"RecurringType.create(:name => "TYPE_BASIC")"...

On Thu, Oct 9, 2008 at 11:52 AM, Scott Taylor
<mailing_lists at railsnewbie.com> wrote:
> On Oct 8, 2008, at 7:40 PM, Wes Gamble wrote:
>> OK, got it.
>> I have a follow-up question though.  If a given spec DID NOT require
>> spec_helper.rb, doesn't that imply that the spec would be run against
>> the Rails "development" environment.
> Basically, the normal operation is that your spec requires spec_helper,
> which eventually requires the test_helper which comes with rails, which sets
> the constant:
> RAILS_ENV = "test"
>> I just did a test where I printed out the configuration of one of my
>> classes DB connnections (e.g. Blah.connection.inspect where Blah is an
>> AR model).  And I saw that the "database" setting in this was
>> development.  My spec definitely inserts data into the DB.
>> I kind of expected to see additional rows in the table in question.
>> But I just realized that each spec is probably surrounded by a
>> transaction - is that correct?
> Yes.  Assuming you have transaction_fixtures = true.  This is how rails
> resets the database between each test (at least after rails 1.2).
> Scott
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list