Sha256: a6ccd366bd7f3e053f3a2997c1cc49018f77569ae41c261cea1fb5bbe523cf9f

Contents?: true

Size: 903 Bytes

Versions: 11

Compression:

Stored size: 903 Bytes

Contents

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

      def included(base)
        base.send :include, UnitProxyProvider
      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_chain :active?, :activations
    end
  end
end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
chanko-2.1.1 lib/chanko/test.rb
chanko-2.1.0 lib/chanko/test.rb
chanko-2.0.8 lib/chanko/test.rb
chanko-2.0.7 lib/chanko/test.rb
chanko-2.0.6 lib/chanko/test.rb
chanko-2.0.5 lib/chanko/test.rb
chanko-2.0.4 lib/chanko/test.rb
chanko-2.0.3 lib/chanko/test.rb
chanko-2.0.2 lib/chanko/test.rb
chanko-2.0.1 lib/chanko/test.rb
chanko-2.0.0 lib/chanko/test.rb