[rspec-users] Module instance variable remains set

Harm harmaarts at gmail.com
Mon Feb 22 14:45:51 EST 2010


I have an issue with rSpec when spec'ing a module. The module in
question looks like this:

module Sheep
  def self.sound
    @sound ||= produce_sound()

This module is used all around the application (and corresponding
specs) and somehow values of @sound leak between each spec. The only
way I found to fix it is to manually set the instance variable (with
instance_variable_set) to nil. Obviously this is Bad. Is there a way
to do this globally or better yet to prevent this?

With kind regards,

More information about the rspec-users mailing list