Hi,
Wondering if anyone can help me here? I'm tearing my hair out. I have a spec that works fine when run singly, but fails if run as part other tests (autospec). It does not depend on anything, and everything it needs is mocked/stubbed.
The spec looks like this:
it "should find inactive users" do @online.save @online1.save @online2.save System.stub!(:cached_attribute).with('TTL').and_return(1) Online.stub! (:inactives_cache_key).and_return(UUID.random_create) sleep 1
Online.cached_find_inactive.should == [@online.user_id, @online1.user_id] end
Where the various @onlines are set in before_each thus:
@online1 = Online.new(:user_id => @user1.id, :status => 2)
Users are just standard users loaded from the fixtures. System TTL is just the time to live used to determine if a user is inactive and the UUID is a cache buster to keep Rails.cache.fetch from caching the value (I've checked. It's not).
Up until about three hours ago it was all working fine and I've rolled back all of my changes. However, no matter what I do now, when autospec runs all the tests, this is the result:
1) 'Online keepalive should find inactive users' FAILED expected: [1, 2], got: (using ==) ./spec/models/onlines_spec.rb:76:
(line 76 is the last line of the spec, above: Online.cached_find...)
However if autospec runs the spec individually or I run it from the textmate rspec bundle, it passes.
Any thoughts or suggestions would be appreciated.