# Strange zentest/rspec behavior

**URL:** <https://www.ruby-forum.com/t/strange-zentest-rspec-behavior/146105>\
**Category:** Rails\
**Created:** [August 17, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/strange-zentest-rspec-behavior/146105 "2008-08-17T23:11:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tatyree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f14d63/32.png) [@tatyree](https://www.ruby-forum.com/u/tatyree)\
**Post date:** [August 17, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/strange-zentest-rspec-behavior/146105/1 "2008-08-17T23:11:34Z")

</div>

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.
