[rspec-users] Module instance variable remains set

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


Hi,

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()
  end
end

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,
Harm



More information about the rspec-users mailing list