Sha256: 18d8090897e08f040f63dfec41561891856489e192387d13e107561fbfd80fc7

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Chanko
  module Test
    class << self
      def activations
        @activations ||= {}
      end

      def included(base)
        base.send :include, UnitProxyProvider
      end

      def logger
        @logger = ::Logger.new(STDOUT)
      end
    end

    def enable_unit(unit_name)
      Test.activations[unit_name] = true
    end
    alias_method :enable_ext, :enable_unit

    def disable_unit(unit_name)
      Test.activations[unit_name] = false
    end
    alias_method :disable_ext, :disable_unit
  end

  module Unit
    module ClassMethods
      def active_with_activations?(*args)
        case Test.activations[unit_name]
        when true
          true
        when false
          false
        else
          active_without_activations?(*args)
        end
      end
      alias_method :active_without_activations?, :active?
      alias_method :active?, :active_with_activations?
    end
  end
end

RSpec.configure do |config|
  config.include Chanko::Test
  config.after { Chanko::Test.activations.clear }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chanko-2.3.0 lib/chanko/test.rb