← Back to Upcase

Confusing AssociationTypeMismatch error

I just started to get lots of AssociationTypeMismatch errors in my Rspec tests. I’m using Guard and noticed the error start on the test I was writing at the time then when I ran the full suite I got:

217 examples, 83 failures, 27 pending

Prior to today all tests were passing fine.

I’m confused by the error because although it’s an AssociationTypeMismatch it’s actually returning the correctly-named model.

Failure/Error: family = create(:family)                                                                                                                   
       School(#47111200) expected, got School(#46218540)

I’m building the particular model in this error, School, in a config.before(:each) support file but I’m also getting the same error relating to other models in the app.

How can I go about debugging this issue?

Hey @weavermedia, any chance you can post the full setup for this test? That would make it easier to help :slight_smile:

The next time I worked on this code the problem had stopped. I still have no idea what the issue was. If it happens again I’ll add more info here.