Sha256: c62dd0fb587074bc33683c78ffbad1564aa398ee8d4947eccdf557b5955d6a0b

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

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.configure do |config|
    config.include Flipper::TestHelp
    config.before(:all) { flipper_configure }
    config.before(:each) { flipper_reset }
  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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-1.2.0 lib/flipper/test_help.rb