Commit 5ac5c764 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'pl-spec-stub-feature-flag-leak-constant' into 'master'

Don't leak constants in stub feature flag spec

See merge request gitlab-org/gitlab!44250
parents 5f4300db 45bd4c8c
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe StubFeatureFlags do
DUMMY_FEATURE_FLAG = :dummy_feature_flag # rubocop:disable RSpec/LeakyConstantDeclaration
let_it_be(:dummy_feature_flag) { :dummy_feature_flag }
# We inject dummy feature flag defintion
# to ensure that we strong validate it's usage
......@@ -11,23 +11,23 @@ RSpec.describe StubFeatureFlags do
before(:all) do
definition = Feature::Definition.new(
nil,
name: DUMMY_FEATURE_FLAG,
name: dummy_feature_flag,
type: 'development',
# we allow ambigious usage of `default_enabled:`
default_enabled: [false, true]
)
Feature::Definition.definitions[DUMMY_FEATURE_FLAG] = definition
Feature::Definition.definitions[dummy_feature_flag] = definition
end
after(:all) do
Feature::Definition.definitions.delete(DUMMY_FEATURE_FLAG)
Feature::Definition.definitions.delete(dummy_feature_flag)
end
describe '#stub_feature_flags' do
using RSpec::Parameterized::TableSyntax
let(:feature_name) { DUMMY_FEATURE_FLAG }
let(:feature_name) { dummy_feature_flag }
context 'when checking global state' do
where(:feature_actors, :expected_result) do
......@@ -140,14 +140,14 @@ RSpec.describe StubFeatureFlags do
describe 'stub timing' do
context 'let_it_be variable' do
let_it_be(:let_it_be_var) { Feature.enabled?(DUMMY_FEATURE_FLAG) }
let_it_be(:let_it_be_var) { Feature.enabled?(dummy_feature_flag) }
it { expect(let_it_be_var).to eq true }
end
context 'before_all variable' do
before_all do
@suite_var = Feature.enabled?(DUMMY_FEATURE_FLAG)
@suite_var = Feature.enabled?(dummy_feature_flag)
end
it { expect(@suite_var).to eq true }
......@@ -155,14 +155,14 @@ RSpec.describe StubFeatureFlags do
context 'before(:all) variable' do
before(:all) do
@suite_var = Feature.enabled?(DUMMY_FEATURE_FLAG)
@suite_var = Feature.enabled?(dummy_feature_flag)
end
it { expect(@suite_var).to eq true }
end
context 'with stub_feature_flags meta' do
let(:var) { Feature.enabled?(DUMMY_FEATURE_FLAG) }
let(:var) { Feature.enabled?(dummy_feature_flag) }
context 'as true', :stub_feature_flags do
it { expect(var).to eq true }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment