Module Feature
In: lib/feature.rb
lib/feature/repository/yaml_repository.rb
lib/feature/repository/simple_repository.rb
lib/feature/repository/redis_repository.rb
lib/feature/repository/active_record_repository.rb
lib/feature/testing.rb
lib/feature/repository.rb
lib/feature/generators/install_generator.rb

This file provides functionality for testing your code with features activated or deactivated. This file should only be required in test/spec code!

To enable Feature testing capabilities do:

  require 'feature/testing'

Methods

Classes and Modules

Module Feature::Repository
Class Feature::InstallGenerator

Public Class methods

Requests if feature is active

@param [Symbol] feature @return [Boolean]

Return list of active feature flags.

@return [Array] list of symbols

Requests if feature is inactive (or unknown)

@param [Symbol] feature @return [Boolean]

Refreshes list of active features from repository. Useful when using an repository with external source.

Execute the code block with the given features active

Example usage:

  Feature.run_with_activated(:feature, :another_feature) do
    # your test code here
  end

Execute the code block with the given features deactive

Example usage:

  Feature.run_with_deactivated(:feature, :another_feature) do
    # your test code here
  end

Set the feature repository The given repository has to respond to method ‘active_featureswith an array of symbols

@param [Object] repository the repository to get the features from @param [Boolean|Integer] refresh optional (default: false) - auto refresh or refresh after given number of seconds

Return value or execute Proc/lambda depending on Feature status.

@param [Symbol] feature @param [Object] value / lambda to use if feature is active @param [Object] value / lambda to use if feature is inactive

Execute the given block if feature is active

@param [Symbol] feature

Execute the given code block and store + restore the feature configuration before/after the execution

Execute the given block if feature is inactive

@param [Symbol] feature

[Validate]