Skip to content
Snippets Groups Projects
Commit 411164f4 authored by Samuel Esposito's avatar Samuel Esposito
Browse files

Add Fabricate.clear_singletons! utility method

Closes #7

LGTM given by: @marten

Squashed commit of the following:

commit 1f1b31c9
Author: Samuel Esposito <s.esposito@roqua.nl>
Date:   Mon Jun 16 22:46:08 2014 +0200

    update change log

commit 0e59e142
Author: Samuel Esposito <s.esposito@roqua.nl>
Date:   Mon Jun 16 22:38:00 2014 +0200

    add clear_singletons! method
parent 38243b4b
No related branches found
Tags v0.1.21
No related merge requests found
## 0.1.9 / 2014-06-18
* add Fabricate.clear_singletons! utility method
## 0.1.8 / 2014-06-17
* catch Mysql2 errors
......
PATH
remote: .
specs:
roqua-support (0.1.8)
roqua-support (0.1.9)
activesupport (>= 3.2, < 5.0)
GEM
remote: https://rubygems.org/
specs:
activesupport (4.1.0)
activesupport (4.1.1)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
......@@ -43,7 +43,7 @@ GEM
rb-inotify (>= 0.9)
lumberjack (1.0.4)
method_source (0.8.2)
minitest (5.3.3)
minitest (5.3.5)
nio4r (1.0.0)
pry (0.9.12.6)
coderay (~> 1.0)
......@@ -66,7 +66,7 @@ GEM
thor (0.18.1)
thread_safe (0.3.4)
timers (1.1.0)
tzinfo (1.1.0)
tzinfo (1.2.1)
thread_safe (~> 0.1)
PLATFORMS
......
module Roqua
module Support
VERSION = "0.1.8"
VERSION = "0.1.9"
end
end
class Fabricate
@singletons = {}
def self.singleton(name, options={}, &block)
@singletons[name] ||= Fabricate(name, options={}, &block)
return @singletons[name]
end
end
\ No newline at end of file
def self.clear_singletons!
@singletons = {}
end
clear_singletons!
end
......@@ -12,5 +12,11 @@ describe Fabricate do
it 'maintains multiple singletons' do
Fabricate.singleton(:one).should_not == Fabricate.singleton(:two)
end
it 'clears singletons' do
the_one = Fabricate.singleton(:one)
Fabricate.clear_singletons!
expect(Fabricate.singleton(:one)).not_to eq(the_one)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment