Sha256: 5595489725949b9be87b6e28addaaed5e205b29f6de6124c2c1a69adf75d4abf

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

require 'helper'

class Features < FeatureDefinitions
  define_feature :AWESOME, using: [:is_awesome?] do |awesome|
    awesome
  end
end

class TestFeatureDefinitions < MiniTest::Unit::TestCase
  def test_feature_enabled
    Features.context = OpenStruct.new(is_awesome?: true)
    assert Features.AWESOME.enabled?
  end
  def test_feature_disabled
    Features.context = OpenStruct.new(is_awesome?: false)
    refute Features.AWESOME.enabled?
  end
  def test_feature_toggle
    Features.context = OpenStruct.new(is_awesome?: true)
    assert Features.AWESOME.enabled?
    Features.context = OpenStruct.new(is_awesome?: false)
    refute Features.AWESOME.enabled?
  end
  def test_feature_toggle_with_block
    Features.context = OpenStruct.new(is_awesome?: true)
    called = false
    Features.AWESOME.enabled? do
      called = true
    end
    assert called
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feature_definitions-0.2.0 test/test_feature_definitions.rb