Inconsistent Test results w/ Autotest vs just rspec ./spec

Problem -------------------------------------------------------

When I run autotest against my rails 3 app, I get some errors that
seem to imply that my @ variables are not be cleared for each
context. It happens only in my controller tests, but that may simply
be a coincidence. When autotest tests either of these controllers in
isolation, the tests pass. The first one is not messing up the second
(I tried commenting out the first breaking test)

When I run the entire spec w/ just rspec ./spec, everything passes. I
tried to emulate what autotest calls with:
bundle exec /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/
bin/ruby -S /Volumes/files/jeffdeville/.rvm/gems/ree-1.8.7-2010.02/
gems/rspec-core-2.3.1/bin/rspec --tty ./spec
(I just replaced the individual file names with ./spec). That worked
fine too.

Environment -------------------------------------------------------

Gemfile bits -----------
group :test, :stress do
gem ‘mongoid-rspec’
gem ‘mocha’
gem “rspec”
gem “rspec-rails”
gem “bourne”
gem ‘factory_girl_rails’
gem “ZenTest”
gem “autotest”
gem “autotest-rails”
gem “cucumber”
gem “launchy”
gem “gherkin”
gem “cucumber-rails”
gem “webrat”
gem “capybara”
gem “capybara-envjs”
gem ‘selenium-client’
gem ‘fakeweb’
gem ‘vcr’
gem “httparty”
gem ‘rpm_contrib’
gem ‘newrelic_rpm’
gem ‘fuubar’
gem ‘ruby-debug’
end

Here are the gem versions being used. I’ve tried to filter it to just
the ones I could see being relevant.
Using ZenTest (4.4.2)
Using autotest (4.4.6)
Using autotest-rails (4.1.0)
Using mocha (0.9.8)
Using bourne (1.0)
Using bundler (1.0.7)
Using term-ansicolor (1.0.5)
Using factory_girl (1.3.2)
Using rails (3.0.3)
Using factory_girl_rails (1.0)
Using rspec-core (2.3.1)
Using rspec-expectations (2.3.0)
Using rspec-mocks (2.3.0)
Using rspec (2.3.0)
Using rspec-instafail (0.1.5)
Using ruby-progressbar (0.0.9)
Using mongoid-rspec (1.3.2)
Using rspec-rails (2.3.1)

I’m using ruby 1.8.7 REE

I’m afraid I don’t really know how autotest works

I didn’t seem to have this problem until recently, so I’m wondering if
a recent release requires me to change something that I missed.

Thanks

On Tue, Dec 21, 2010 at 9:26 PM, JDeville [email protected] wrote:

When I run the entire spec w/ just rspec ./spec, everything passes. I
tried to emulate what autotest calls with:
bundle exec /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/
bin/ruby -S /Volumes/files/jeffdeville/.rvm/gems/ree-1.8.7-2010.02/
gems/rspec-core-2.3.1/bin/rspec --tty ./spec
(I just replaced the individual file names with ./spec). That worked
fine too.

Replacing the filenames with ./spec won’t necessarily get you the same
result as having all the filenames spelled out. Autotest has a bunch
of strategies for ordering files. The default is “random”.

In my experience, what you’re seeing happens because there is a leaky
example (one that leaves some global state modified) that only causes
problems when run before other examples that rely on that bit of
state. Try running the examples using different autotest ordering
strategies and see what happens. Just put this in a .autotest file in
the root of the project:

Autotest.add_hook :initialize do |autotest|
autotest.order = :alpha
end

Valid values are :alpha, :reverse, :random, :natural.

HTH,
David