Skip to content

Commit

Permalink
normalize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gardleopard committed Jul 5, 2023
1 parent 5c463f4 commit 183685b
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions spec/unleash/strategy/flexible_rollout_spec.rb
Expand Up @@ -5,7 +5,7 @@
let(:strategy) { Unleash::Strategy::FlexibleRollout.new }
let(:unleash_context) { Unleash::Context.new }

it 'should always be enabled when rollout is set to 100, disabled when set to 0' do
it 'should always be enabled when stickiness is default and rollout is set to 100' do
params = {
'groupId' => 'Demo',
'rollout' => 100,
Expand All @@ -14,8 +14,39 @@

expect(strategy.is_enabled?(params, unleash_context)).to be_truthy
expect(strategy.is_enabled?(params, nil)).to be_truthy
expect(strategy.is_enabled?(params.merge({ 'rollout' => 0 }), unleash_context)).to be_falsey
expect(strategy.is_enabled?(params.merge({ 'rollout' => 0 }), nil)).to be_falsey
end

it 'should always be disabled when stickiness is default and rollout is set to 0' do
params = {
'groupId' => 'Demo',
'rollout' => 0,
'stickiness' => 'default'
}

expect(strategy.is_enabled?(params, unleash_context)).to be_falsey
expect(strategy.is_enabled?(params, nil)).to be_falsey
end

it 'should always be enabled when stickiness is random and rollout is set to 100' do
params = {
'groupId' => 'Demo',
'rollout' => 100,
'stickiness' => 'random'
}

expect(strategy.is_enabled?(params, unleash_context)).to be_truthy
expect(strategy.is_enabled?(params, nil)).to be_truthy
end

it 'should always be disabled when stickiness is random and rollout is set to 0' do
params = {
'groupId' => 'Demo',
'rollout' => 0,
'stickiness' => 'random'
}

expect(strategy.is_enabled?(params, unleash_context)).to be_falsey
expect(strategy.is_enabled?(params, nil)).to be_falsey
end

it 'should behave predictably when based on the normalized_number' do
Expand Down Expand Up @@ -45,6 +76,7 @@
)

expect(strategy.is_enabled?(params, custom_context)).to be_truthy
expect(strategy.is_enabled?(params, nil)).to be_falsey
end

it 'should be disabled when stickiness=customerId and customerId=63 and rollout=10' do
Expand All @@ -61,6 +93,7 @@
)

expect(strategy.is_enabled?(params, custom_context)).to be_falsey
expect(strategy.is_enabled?(params, nil)).to be_falsey
end
end
end

0 comments on commit 183685b

Please sign in to comment.