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:

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/

On 7 Apr 2008, at 21:01, Ashley M. wrote:

The fix is to put this at the top of the controller file:
require_dependency “user_state”

I spoke to soon :frowning:

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/

On Mon, Apr 7, 2008 at 4:08 PM, Ashley M.
[email protected] wrote:

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 :slight_smile:

On 7 Apr 2008, at 21:09, David C. wrote:

Did anything else change in your setup? Rails version? Autotest
version? Just checking :slight_smile:

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/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs