Skip to content

Instantly share code, notes, and snippets.

@iagooar
Created March 30, 2012 09:34
Show Gist options
  • Select an option

  • Save iagooar/2250342 to your computer and use it in GitHub Desktop.

Select an option

Save iagooar/2250342 to your computer and use it in GitHub Desktop.
Test Ruby Singleton Classes
class MySingletonClass
include Singleton
def initialize
## Do some initializing
end
## Your business logic
end
describe MySingletonClass
before do
class MySingletonClass
def self.reset
Singleton.send :__init__, self
end
end
end
## Write some fancy specs
context 'new context which requires a fresh MySingletonClass instance' do
before do
MySingletonClass.reset
end
## Some more specs
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment