[Rspec-devel] run specs FAST with rails_spec

aslak hellesoy aslak.hellesoy at gmail.com
Sat Aug 19 06:41:04 EDT 2006


On 8/18/06, Daniel Siemssen <daniel at dr-siemssen.de> wrote:
> On 18.08.2006 02:36, aslak hellesoy wrote:
> > On 8/17/06, Daniel Siemssen <daniel at dr-siemssen.de> wrote:
> >
> >> On 04.07.2006 16:59, aslak hellesoy wrote:
> >>
> >>> On 7/4/06, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> >>>
> >>>
> >>>> Probably nothing.  The tests completed in no time!  But then I ran them
> >>>> again, and they all failed, with errors like:
> >>>>
> >>>>
> >>> I get a similar error running from the demo app. However it's the
> >>> model classes that aren't found - not the ficture ones:
> >>>
> >>> $ script/rails_spec spec/models/person_spec.rb
> >>>
> >>> 1)
> >>> NameError in 'The Person model should find an existing person'
> >>> uninitialized constant Person
> >>>
> >>> etc.....
> >>>
> >>>
> >>>
> >>>> FixtureClassNotFound in 'The BBB receipt can handle adding the bunny
> >>>> slippers'
> >>>> The class "Receipt" was not found.
> >>>> /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:403:in
> >>>> `find'
> >>>> ./spec/models/receipt_spec.rb:68:in `setup'
> >>>> script/rails_spec_runner:25:in `run'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1552:in `perform_without_block'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1512:in `perform'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1427:in `run'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1424:in `run'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1344:in `initialize'
> >>>> /usr/lib/ruby/1.8/drb/drb.rb:1624:in `start_service'
> >>>> script/rails_spec_runner:46
> >>>>
> >>>> Finished in 0.341 seconds
> >>>>
> >>>> 32 specifications, 32 failures
> >>>>
> >>>> Did I miss a step, or is this a bug with rails_spec_runner's handling of
> >>>> fixtures?
> >>>>
> >>>>
> >>>>
> >>> This is definitely a bug, and it's not fixture specific. Nothing works
> >>> on a second run.
> >>> I don't know what's causing this yet.
> >>>
> >>> And it needs to get fixed!
> >>>
> >>> Aslak
> >>>
> >>>
> >>>
> >> The models fail to load in the second run because rails can't reload the
> >> models after Dispatcher.reset_application! in test mode. Why is rails
> >> doing that? Because config.cache_classes = true by default in test mode
> >> and the initialize_dependency_mechanism in Rails::Initializer sets the
> >> Dependencies.mechanism depending on the value of config.cache_classes.
> >> Thus Dependencies.mechanism = :load is reset to :require after the first
> >> call of Dispatcher.reset_application! and models won't get loaded
> >> anymore. All you have to do is put a Dependencies.mechanism = :load
> >> before the "Dispatcher.reset_application!"-line or set cache_classes =
> >> false.
> >>
> >>
> >
> > Does this mean you've succeeded in getting the fast rails drb spec
> > runner working?
> > Would be awesome.
> >
> > Aslak
> >
> >
> Yes, got it running. I'll send you a mail with the patches.

Thanks a lot Daniel. For the future, please submit patches in RSpec's
tracker at Rubyforge.

I have committed your patch, but my controller specs are still failing
on the second run. (Model specs can run many times and also do seem to
get reloaded, which is great).

I'm running the specs for the demo app that the rspec_on_rails plugin lives in:

Shell 1:
cd vendor/rspec_on_rails
script/rails_spec_runner

Shell 2:
cd vendor/rspec_on_rails
script/rails_spec spec/models
script/rails_spec spec/models
script/rails_spec spec/controllers
script/rails_spec spec/controllers #fails

Any idea what causes this or how to fix it?

Cheers,
Aslak

> >> Daniel
> >> _______________________________________________
> >> Rspec-devel mailing list
> >> Rspec-devel at rubyforge.org
> >> http://rubyforge.org/mailman/listinfo/rspec-devel
> >>
> >>
> > _______________________________________________
> > Rspec-devel mailing list
> > Rspec-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-devel
> >
>
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the Rspec-devel mailing list