[rspec-users] spec_server not reloading model classes

Andrew Vit andrew at avit.ca
Sun Mar 29 19:14:13 EDT 2009


It appears this is a bug, with an apparently simple fix in
spec_server.rb (rails 2.3 compatibility):

https://rspec.lighthouseapp.com/projects/5645/tickets/759

However, now that it's reloading my app, it's not reloading the setup
from my fixture/factory gems and throwing up a bunch of errors on re-
run. (I've tried it with both factory_girl and machinist now.) These
are required in my spec_helper.rb:

config.gem 'notahat-machinist', :lib => 'machinist', :source =>
'http://gems.github.com'
require File.dirname(__FILE__) + '/blueprints'

or:

config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source
=> 'http://gems.github.com'
# automatically loaded from spec/factories/*.rb

Not sure where to look for a solution.


On Mar 29, 3:15 am, Andrew Vit <and... at avit.ca> wrote:
> On Mar 29, 1:40 am, Scott Taylor <sc... at railsnewbie.com> wrote:
>
> > Actually I meant poking around your app with a browser in dev mode ;)
>
> Ok, I get it, I wasn't sure what you were driving at! ;-) Yes,
> everything is reloading fine in the browser under development.
>
> > I'm pretty sure that rails will still try to run the test environment,
> > even with RAILS_ENV set to a different value, anyway.
>
> The RAILS_ENV is being set conditionally in my script files, except
> script/autospec where it isn't defined.
> ENV["RAILS_ENV"] ||= 'test'
>
> > I was thinking of any explicit requires which may occur in app/ and lib/.
>
> Nothing out of the ordinary...
>
> > AFAIK, this is more of a rails loading issue than an rspec one.
>
> I just tried this on a clean new rails app, and the reloading still
> doesn't work when running spec_server and autospec with --drb. It
> works fine when I'm not using spec_server, but then it reloads all of
> rails each time. Works fine, except when using spec_server.
>
> The rspec site says:
> [http://rspec.info/rails/runners.html]
>
> > Note that there are some classes and modules that, by default, won’t get reloaded
> > by Rails, which means they won’t be reloaded by spec_server. There are a number
> > of strategies available for coercing Rails to reload files every time in a given
> > environment. See the Rails documentation for more information.
>
> Does that include my app/models? I wouldn't have thought so... Another
> post on this mailing list seemed to suggest those don't need manual
> reloading and "just work".
>
> $ gem list rails
> rails (2.3.2)
> $ gem list rspec
> rspec (1.2.2)
> rspec-rails (1.2.2)
> $ rails test_spec_server && cd test_spec_server
> $ script/plugin install git://github.com/dchelimsky/rspec-rails.git
> $ script/generate rspec
> $ script/generate rspec_model car name:string
> # edit config/environments/test.rb => config.cache_classes = false
> # edit spec/spec.opts => --drb
> $ rake spec:server:start
> $ script/autospec
> # 1 example, 0 failures
> # edit app/models/car.rb => add invalid syntax!
> # 1 example, 0 failures
>
> Can anyone confirm/reproduce? (Or else tell me what I'm doing wrong?)
>
> Thanks,
> Andrew Vit
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list