Sha256: 4e5ce59d0caf9694aad1250fa29c223a4627fcdccce7a1d29ad8a8ea6b82a2ec

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 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.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

Version data entries

1 entries across 1 versions & 1 rubygems

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