[rspec-users] spec_server errors when reloading fixture replacement plugins (was: spec_server not reloading model classes)
andrew at avit.ca
Fri May 1 13:16:19 EDT 2009
On May 1, 2009, at 7:04 AM, David Chelimsky wrote:
> On Sun, Mar 29, 2009 at 6:14 PM, Andrew Vit <andrew at avit.ca> wrote:
>> It appears this is a bug, with an apparently simple fix in
>> spec_server.rb (rails 2.3 compatibility):
>> 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 =>
>> require File.dirname(__FILE__) + '/blueprints'
>> config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source
>> => 'http://gems.github.com'
>> # automatically loaded from spec/factories/*.rb
> In spec_helper?
Sorry, that wasn't clear the way I wrote it. The config.gem directive
was actually in the rails/environments/test.rb file. Then I required
the blueprints.rb file in spec_helper (or in factory_girl's case it
automatically loads the factory files from spec/factories). These
steps showed that rails model reloading wasn't working in 1.2.2 with
>>> $ 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
I had given up on spec_server for the time being. The ticket is
resolved now, and I just gave these steps another try with a new app
using updated versions. Reloading the app classes for each run works
fine out of the box now: I can get it to return a success or failure
when I change the model on the fly.
However, the problem comes when adding Factory Girl:
config.gem "thoughtbot-factory_girl", :lib => 'factory_girl'
Factory.define :car do |f|
it "should create a new instance given valid attributes" do
car = Factory :car
car.name.should == 'Jetta'
It runs fine the first time against drb, but on all subsequent runs I
get the following error until I restart spec_server. None of the lines
in the stacktrace say "rspec" but I was also getting the same error
with Machinist too, so it's not unique to Factory Girl, and I'm
guessing something to do with the reloading.
TypeError in 'Car should create a new instance given valid attributes'
can't dup NilClass
More information about the rspec-users