Created
March 30, 2012 09:34
-
-
Save matisojka/2250342 to your computer and use it in GitHub Desktop.
Test Ruby Singleton Classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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