guard-jruby-rspec icon indicating copy to clipboard operation
guard-jruby-rspec copied to clipboard

instance_of? not functioning correctly on second run

Open mattbeedle opened this issue 11 years ago • 3 comments

The first time around all of my tests pass. The second time around I have failures related to ActiveRecord equality comparisons.

This fails for example

User.deactivated.should include(user)

Taking a closer look:

user.class # => User(id: integer, email: string, encrypted_password: string, .........)

user.instance_of?(user.class) # => true 

User.deactivated.first.class # => User(id: integer, email: string, encrypted_password: string, .........)

User.deactivated.instance_of(user.class) # => false

u = User.new
u.instance_of?(user.class) # => false
u.instance_of?(User.deactivated.class) # => true

I think this issue may be related to #31

/cc @nilbus

mattbeedle avatar May 31 '13 16:05 mattbeedle

Yes, very likely related.

nilbus avatar May 31 '13 21:05 nilbus

I tried creating a bare bones rails app, just with devise, fabrication and rspec and this seems to work fine there:

https://github.com/mattbeedle/guard_jruby_rspec_example

So, I'm not totally sure where to start looking for this issue now. Any ideas? Maybe I should try adding all the additional gems from my main app 1 by 1?

mattbeedle avatar Jun 01 '13 08:06 mattbeedle

OK, I found the cause. It happens when class caching is turned off in config/environments/test.rb.

mattbeedle avatar Jun 01 '13 10:06 mattbeedle