Coming soon! A Pro version of the Flipper gem for entirely local installations.

Get Updates

Documentation

Testing

Advice and insights related to best practices for testing feature flags in your application.

Since 1.2.0, Flipper will default to the Memory adapter when running tests in a Rails app and reset it before each test. This means each test is run with a fresh instance of Flipper and all features disabled. We find this the best route, but your application may have different needs. If you want some features to always be enabled, you can enable them in your test setup.

class ActiveSupport::TestCase
  setup do
    Flipper.enable :accounts
    Flipper.enable :plausible
  end
end

In the example above, the accounts and plausible features would both start enabled for every test. Every other feature flag would start disabled.

Test Both Sides

For any feature flag, we strongly encourage you to have at least one test for when the feature is enabled and disabled. This ensures both sides of the coin are tested.

require 'test_helper'

class DocumentationControllerTest < ActionDispatch::IntegrationTest
  test "returns 404 for documentation when feature disabled" do
    Flipper.disable(:docs)
    get documentation_path
    assert_response :not_found
  end

  test "renders documentation when feature enabled" do
    Flipper.enable(:docs)
    get documentation_path
    assert_response :success
  end
end

System Tests

The default configuration for testing should work for system tests just as any other test. Let us know on this issue if you run into any issues.

Advanced

For non-Rails apps or Flipper <1.2, see test_help.rb.

Ready to try it out?

Get audit history, rollbacks, advanced permissions, analytics, and all of your projects in one place.


Prefer our Cloudless option?

You can choose from several tiers to sponsor Flipper on GitHub and get some great benefits!

The Friday Deploy

Get updates for all things Flipper—open source and cloud.

Have questions? Need help?

Email us any time or head on over to our documentation or status page for the latest on the app or API.

Ready to take Flipper for a swim?

No credit card required. 14-day free trial. And customer support directly from the developers.