[rspec-users] Testing discovered a problem in my code

Fernando Perez lists at ruby-forum.com
Thu Apr 16 07:51:57 EDT 2009

When trying to test using sqlite in-memory in ran into a problem:

- rake test raises an error on a test
- running the failing test alone works perfectly.

So what's the problem? here is the method giving the trouble:

def self.expiry_date_for(user)
  @expiry_date_cache ||= find_if_expiry_date_for(user)

That cached method is also called by another file, and therefore sets
the @expiry_date_cache to some value therefore not acting correctly.

So is my code flawed or is it the testing framework that doesn't clear
correctly the cached variable? In production, would my code work
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list