diff options
Diffstat (limited to 'spec/experiments')
-rw-r--r-- | spec/experiments/application_experiment_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb index 76fdcd222d1..5c5f563a803 100644 --- a/spec/experiments/application_experiment_spec.rb +++ b/spec/experiments/application_experiment_spec.rb @@ -5,6 +5,14 @@ require 'spec_helper' RSpec.describe ApplicationExperiment, :experiment do subject { described_class.new(:stub) } + let(:feature_definition) { { name: 'stub', type: 'experiment', group: 'group::adoption', default_enabled: false } } + + around do |example| + Feature::Definition.definitions[:stub] = Feature::Definition.new('stub.yml', feature_definition) + example.run + Feature::Definition.definitions.delete(:stub) + end + before do allow(subject).to receive(:enabled?).and_return(true) end @@ -105,6 +113,12 @@ RSpec.describe ApplicationExperiment, :experiment do end describe "variant resolution" do + it "uses the default value as specified in the yaml" do + expect(Feature).to receive(:enabled?).with('stub', subject, type: :experiment, default_enabled: :yaml) + + expect(subject.variant.name).to eq('control') + end + it "returns nil when not rolled out" do stub_feature_flags(stub: false) |