Features.Test (features v0.1.0) View Source

To test featured code you have to set features property to enable runtime execution (it replaces the compile-time deletion).

On test.exs:

config :features, test: true

On test_helpers.exs:

Features.Test.start()

On a test:

defmodule MyModuleTest do
  use ExUnit.Case, async: true
  use Features.Test

  featured_test "test1", features: [:a_feature, :another_feature] do
    assert MyModule.do_something() == :another_feature_is_enabled
  end

  featured_test "test2", features: [:a_feature] do
    assert MyModule.do_something() == :another_feature_is_disabled
  end

  featured_test "test3", features: [] do
    assert_raise CaseClauseError, fn -> MyModule.do_something() end
  end
end

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

featured_test "test2", features: [:a_feature] do
  assert MyModule.do_something() == :another_feature_is_disabled
end

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.