-
-
Notifications
You must be signed in to change notification settings - Fork 422
/
Copy pathtest_help.rb
38 lines (33 loc) · 884 Bytes
/
test_help.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Flipper
module TestHelp
def flipper_configure
# Create a single shared memory adapter instance for each test
@flipper_adapter = Flipper::Adapters::Memory.new
Flipper.configure do |config|
config.adapter { @flipper_adapter }
config.default { Flipper.new(config.adapter) }
end
end
def flipper_reset
Flipper.instance = nil # Reset previous flipper instance
end
end
end
if defined?(RSpec) && RSpec.respond_to?(:configure)
RSpec.configure do |config|
config.include Flipper::TestHelp
config.before(:each) do
flipper_reset
flipper_configure
end
end
end
if defined?(ActiveSupport)
ActiveSupport.on_load(:active_support_test_case) do
ActiveSupport::TestCase.class_eval do
include Flipper::TestHelp
setup :flipper_configure
setup :flipper_reset
end
end
end