summaryrefslogtreecommitdiff
path: root/spec/support_specs/helpers/stub_feature_flags_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support_specs/helpers/stub_feature_flags_spec.rb')
-rw-r--r--spec/support_specs/helpers/stub_feature_flags_spec.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/spec/support_specs/helpers/stub_feature_flags_spec.rb b/spec/support_specs/helpers/stub_feature_flags_spec.rb
index 57dd3015f5e..8629e895fd1 100644
--- a/spec/support_specs/helpers/stub_feature_flags_spec.rb
+++ b/spec/support_specs/helpers/stub_feature_flags_spec.rb
@@ -5,19 +5,20 @@ require 'spec_helper'
RSpec.describe StubFeatureFlags do
let_it_be(:dummy_feature_flag) { :dummy_feature_flag }
- # We inject dummy feature flag defintion
- # to ensure that we strong validate it's usage
- # as well
- before(:all) do
- definition = Feature::Definition.new(
+ let_it_be(:dummy_definition) do
+ Feature::Definition.new(
nil,
name: dummy_feature_flag,
type: 'development',
- # we allow ambigious usage of `default_enabled:`
- default_enabled: [false, true]
+ default_enabled: false
)
+ end
- Feature::Definition.definitions[dummy_feature_flag] = definition
+ # We inject dummy feature flag defintion
+ # to ensure that we strong validate it's usage
+ # as well
+ before(:all) do
+ Feature::Definition.definitions[dummy_feature_flag] = dummy_definition
end
after(:all) do
@@ -47,6 +48,10 @@ RSpec.describe StubFeatureFlags do
it { expect(Feature.disabled?(feature_name)).not_to eq(expected_result) }
context 'default_enabled does not impact feature state' do
+ before do
+ allow(dummy_definition).to receive(:default_enabled).and_return(true)
+ end
+
it { expect(Feature.enabled?(feature_name, default_enabled: true)).to eq(expected_result) }
it { expect(Feature.disabled?(feature_name, default_enabled: true)).not_to eq(expected_result) }
end
@@ -79,6 +84,10 @@ RSpec.describe StubFeatureFlags do
it { expect(Feature.disabled?(feature_name, actor(tested_actor))).not_to eq(expected_result) }
context 'default_enabled does not impact feature state' do
+ before do
+ allow(dummy_definition).to receive(:default_enabled).and_return(true)
+ end
+
it { expect(Feature.enabled?(feature_name, actor(tested_actor), default_enabled: true)).to eq(expected_result) }
it { expect(Feature.disabled?(feature_name, actor(tested_actor), default_enabled: true)).not_to eq(expected_result) }
end