Ashley Moran
2008-Apr-07 20:01 UTC
[rspec-users] Why do I have to require_dependency here?
Hi This was bugging the hell out of me until I found a fix just. I have been getting reams and reams of errors from reference to one model class in a controller spec. Here''s one of the 57 that go wrong: 20) LoadError in ''UsersController PUT /users/:id when the model is invalid and there is no primary user issue and the user clicked Save should not assign the primary user issue to the view'' Expected /Users/ashleymoran/Documents/TechnoPhobia/becta/apps/Backend/ app/models/user_state.rb to define UserState ./spec/controllers/users_controller_spec.rb:343: script/spec:4: But the weird thing is it ONLY happens when you run the spec in isolation. As part of a full autotest run, it''s fine. The fix is to put this at the top of the controller file: require_dependency "user_state" Any idea what could be going wrong? It''s not the first class loader issue I''ve hit, when I see a pattern I''ll file a ticket. Just wondered if this was new to everyone here. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/
Ashley Moran
2008-Apr-07 20:08 UTC
[rspec-users] Why do I have to require_dependency here?
On 7 Apr 2008, at 21:01, Ashley Moran wrote:> The fix is to put this at the top of the controller file: > require_dependency "user_state"I spoke to soon :( This fixes it for a single controller run, but still breaks when autotest re-runs the one controller after making a change. Something''s really wrong with class loading and I''m pretty sure it was introduced between 1.1.3 and r3333. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/
David Chelimsky
2008-Apr-07 20:09 UTC
[rspec-users] Why do I have to require_dependency here?
On Mon, Apr 7, 2008 at 4:08 PM, Ashley Moran <ashley.moran at patchspace.co.uk> wrote:> > On 7 Apr 2008, at 21:01, Ashley Moran wrote: > > > The fix is to put this at the top of the controller file: > > require_dependency "user_state" > > > I spoke to soon :( > > This fixes it for a single controller run, but still breaks when > autotest re-runs the one controller after making a change. > Something''s really wrong with class loading and I''m pretty sure it was > introduced between 1.1.3 and r3333.Did anything else change in your setup? Rails version? Autotest version? Just checking :)> > > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Ashley Moran
2008-Apr-07 20:28 UTC
[rspec-users] Why do I have to require_dependency here?
On 7 Apr 2008, at 21:09, David Chelimsky wrote:> Did anything else change in your setup? Rails version? Autotest > version? Just checking :)Hmm, can''t think of anything. Rails has been 2.0.2 since I started, don''t remember ever upgrading Autotest, at the very most it was 3.9.1 to 3.9.2 (but I think I always had 3.9.2 at work). I''m really puzzled what''s going on... Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/