Skip to content

Config option to automatically enable features if a "test mode" proc is true #1

@asross

Description

@asross

Here's an example of what I'm thinking:

# config/initializers/binflip.rb

$toggle = Binflip.new
$toggle.always_enable_if -> { Rails.env.test? }
#$toggle.always_enable_if -> { ENV['RACK_ENV'] == 'test' }

Basically, this would be a way of ensuring that all features are always active in test mode, to prevent having to worry about toggling in tests.

If we want to test that/how a feature is toggled off, could add an additional:

describe "my feature" do
  it "can be toggled off" do
    $toggle.ensure_disabled(:my_feature) do
      # visit the page and assert it's gone
    end
  end
end

Which would provide a block inside of which $toggle.active?(:my_feature) returns false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions