flipper 1.4.1 → 1.5.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +70 -10
- data/lib/flipper/adapter.rb +24 -0
- data/lib/flipper/adapter_builder.rb +12 -1
- data/lib/flipper/adapters/actor_limit.rb +4 -3
- data/lib/flipper/adapters/cache_base.rb +17 -0
- data/lib/flipper/adapters/dual_write.rb +12 -0
- data/lib/flipper/adapters/failover.rb +15 -0
- data/lib/flipper/adapters/failsafe.rb +16 -0
- data/lib/flipper/adapters/http/client.rb +7 -3
- data/lib/flipper/adapters/http/redacted_debug_output.rb +70 -0
- data/lib/flipper/adapters/http.rb +42 -8
- data/lib/flipper/adapters/instrumented.rb +28 -0
- data/lib/flipper/adapters/memoizable.rb +21 -5
- data/lib/flipper/adapters/memory.rb +63 -31
- data/lib/flipper/adapters/poll.rb +51 -6
- data/lib/flipper/adapters/pstore.rb +15 -0
- data/lib/flipper/adapters/read_only.rb +1 -1
- data/lib/flipper/adapters/strict.rb +17 -1
- data/lib/flipper/adapters/sync/feature_synchronizer.rb +3 -1
- data/lib/flipper/adapters/sync/synchronizer.rb +20 -1
- data/lib/flipper/adapters/sync.rb +8 -0
- data/lib/flipper/adapters/wrapper.rb +7 -0
- data/lib/flipper/cli.rb +87 -22
- data/lib/flipper/cloud/configuration.rb +136 -21
- data/lib/flipper/cloud/dsl.rb +6 -0
- data/lib/flipper/cloud/memory_adapter.rb +43 -0
- data/lib/flipper/cloud/message_verifier.rb +1 -0
- data/lib/flipper/cloud/middleware.rb +8 -3
- data/lib/flipper/cloud/migrate.rb +3 -1
- data/lib/flipper/cloud/routes.rb +24 -2
- data/lib/flipper/cloud/shared_memory.rb +84 -0
- data/lib/flipper/cloud/telemetry.rb +56 -28
- data/lib/flipper/cloud/url_validator.rb +26 -0
- data/lib/flipper/cloud.rb +22 -4
- data/lib/flipper/configuration.rb +86 -3
- data/lib/flipper/dsl.rb +47 -3
- data/lib/flipper/engine.rb +64 -8
- data/lib/flipper/errors.rb +18 -0
- data/lib/flipper/export.rb +4 -0
- data/lib/flipper/exporters/json/export.rb +6 -0
- data/lib/flipper/exporters/json/v1.rb +5 -9
- data/lib/flipper/expression/constant.rb +6 -0
- data/lib/flipper/expression.rb +105 -1
- data/lib/flipper/expressions/comparable.rb +5 -0
- data/lib/flipper/expressions/feature_enabled.rb +11 -7
- data/lib/flipper/expressions/number.rb +2 -0
- data/lib/flipper/expressions/percentage.rb +3 -1
- data/lib/flipper/expressions/percentage_of_actors.rb +9 -0
- data/lib/flipper/expressions/random.rb +2 -0
- data/lib/flipper/expressions/sem_ver.rb +24 -0
- data/lib/flipper/expressions/time.rb +9 -1
- data/lib/flipper/feature.rb +153 -43
- data/lib/flipper/feature_check_context.rb +19 -1
- data/lib/flipper/gates/actor.rb +4 -1
- data/lib/flipper/gates/expression.rb +17 -2
- data/lib/flipper/gates/group.rb +1 -1
- data/lib/flipper/gates/percentage_of_actors.rb +19 -2
- data/lib/flipper/gates/percentage_of_time.rb +4 -1
- data/lib/flipper/groups.rb +66 -0
- data/lib/flipper/instrumentation/log_subscriber.rb +6 -1
- data/lib/flipper/instrumentation/subscriber.rb +21 -2
- data/lib/flipper/middleware/memoizer.rb +5 -2
- data/lib/flipper/named_configuration.rb +194 -0
- data/lib/flipper/named_proxy.rb +46 -0
- data/lib/flipper/poller.rb +39 -19
- data/lib/flipper/sem_ver.rb +84 -0
- data/lib/flipper/spec/shared_adapter_specs.rb +40 -0
- data/lib/flipper/sync_version.rb +61 -0
- data/lib/flipper/test_help.rb +50 -0
- data/lib/flipper/typecast.rb +15 -0
- data/lib/flipper/types/group.rb +2 -2
- data/lib/flipper/version.rb +1 -1
- data/lib/flipper.rb +183 -65
- data/lib/generators/flipper/setup_generator.rb +18 -0
- data/lib/generators/flipper/table_prefix.rb +44 -0
- data/lib/generators/flipper/templates/initializer.rb +7 -0
- data/lib/generators/flipper/templates/update/migrations/01_create_flipper_tables.rb.erb +13 -7
- data/lib/generators/flipper/templates/update/migrations/02_change_flipper_gates_value_to_text.rb.erb +12 -7
- data/lib/generators/flipper/update_generator.rb +3 -0
- metadata +42 -171
- data/.codeclimate.yml +0 -3
- data/.github/FUNDING.yml +0 -1
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/ci.yml +0 -110
- data/.github/workflows/examples.yml +0 -105
- data/.github/workflows/release.yml +0 -54
- data/.rspec +0 -1
- data/.superset/config.json +0 -4
- data/CLAUDE.md +0 -93
- data/CODE_OF_CONDUCT.md +0 -46
- data/Dockerfile +0 -27
- data/Gemfile +0 -41
- data/Rakefile +0 -54
- data/benchmark/enabled_ips.rb +0 -10
- data/benchmark/enabled_multiple_actors_ips.rb +0 -20
- data/benchmark/enabled_profile.rb +0 -20
- data/benchmark/instrumentation_ips.rb +0 -21
- data/benchmark/typecast_ips.rb +0 -27
- data/docker-compose.yml +0 -37
- data/docs/DockerCompose.md +0 -18
- data/docs/README.md +0 -1
- data/docs/images/banner.jpg +0 -0
- data/docs/images/flipper_cloud.png +0 -0
- data/examples/api/basic.ru +0 -18
- data/examples/api/custom_memoized.ru +0 -36
- data/examples/api/memoized.ru +0 -42
- data/examples/basic.rb +0 -19
- data/examples/cloud/app.ru +0 -12
- data/examples/cloud/backoff_policy.rb +0 -13
- data/examples/cloud/basic.rb +0 -22
- data/examples/cloud/cloud_setup.rb +0 -20
- data/examples/cloud/forked.rb +0 -36
- data/examples/cloud/import.rb +0 -17
- data/examples/cloud/poll_interval/README.md +0 -111
- data/examples/cloud/poll_interval/client.rb +0 -108
- data/examples/cloud/poll_interval/server.rb +0 -98
- data/examples/cloud/threaded.rb +0 -33
- data/examples/configuring_default.rb +0 -19
- data/examples/dsl.rb +0 -57
- data/examples/enabled_for_actor.rb +0 -37
- data/examples/expressions.rb +0 -237
- data/examples/group.rb +0 -38
- data/examples/group_dynamic_lookup.rb +0 -75
- data/examples/group_with_members.rb +0 -83
- data/examples/importing.rb +0 -29
- data/examples/individual_actor.rb +0 -28
- data/examples/instrumentation.rb +0 -42
- data/examples/instrumentation_last_accessed_at.rb +0 -38
- data/examples/memoizing.rb +0 -35
- data/examples/mirroring.rb +0 -59
- data/examples/percentage_of_actors.rb +0 -31
- data/examples/percentage_of_actors_enabled_check.rb +0 -35
- data/examples/percentage_of_actors_group.rb +0 -35
- data/examples/percentage_of_time.rb +0 -27
- data/examples/strict.rb +0 -18
- data/flipper-cloud.gemspec +0 -19
- data/flipper.gemspec +0 -42
- data/package-lock.json +0 -41
- data/package.json +0 -10
- data/spec/fixtures/environment.rb +0 -1
- data/spec/fixtures/feature.json +0 -31
- data/spec/fixtures/flipper_pstore_1679087600.json +0 -46
- data/spec/flipper/actor_spec.rb +0 -56
- data/spec/flipper/adapter_builder_spec.rb +0 -72
- data/spec/flipper/adapter_spec.rb +0 -166
- data/spec/flipper/adapters/actor_limit_spec.rb +0 -75
- data/spec/flipper/adapters/dual_write_spec.rb +0 -82
- data/spec/flipper/adapters/failover_spec.rb +0 -141
- data/spec/flipper/adapters/failsafe_spec.rb +0 -58
- data/spec/flipper/adapters/http/client_spec.rb +0 -61
- data/spec/flipper/adapters/http_spec.rb +0 -596
- data/spec/flipper/adapters/instrumented_spec.rb +0 -167
- data/spec/flipper/adapters/memoizable_spec.rb +0 -377
- data/spec/flipper/adapters/memory_spec.rb +0 -36
- data/spec/flipper/adapters/operation_logger_spec.rb +0 -128
- data/spec/flipper/adapters/poll_spec.rb +0 -41
- data/spec/flipper/adapters/pstore_spec.rb +0 -16
- data/spec/flipper/adapters/read_only_spec.rb +0 -100
- data/spec/flipper/adapters/strict_spec.rb +0 -122
- data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +0 -247
- data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +0 -33
- data/spec/flipper/adapters/sync/synchronizer_spec.rb +0 -175
- data/spec/flipper/adapters/sync_spec.rb +0 -213
- data/spec/flipper/cli_spec.rb +0 -217
- data/spec/flipper/cloud/configuration_spec.rb +0 -257
- data/spec/flipper/cloud/dsl_spec.rb +0 -90
- data/spec/flipper/cloud/message_verifier_spec.rb +0 -104
- data/spec/flipper/cloud/middleware_spec.rb +0 -307
- data/spec/flipper/cloud/migrate_spec.rb +0 -160
- data/spec/flipper/cloud/telemetry/backoff_policy_spec.rb +0 -107
- data/spec/flipper/cloud/telemetry/metric_spec.rb +0 -87
- data/spec/flipper/cloud/telemetry/metric_storage_spec.rb +0 -58
- data/spec/flipper/cloud/telemetry/submitter_spec.rb +0 -145
- data/spec/flipper/cloud/telemetry_spec.rb +0 -208
- data/spec/flipper/cloud_spec.rb +0 -186
- data/spec/flipper/configuration_spec.rb +0 -50
- data/spec/flipper/dsl_spec.rb +0 -346
- data/spec/flipper/engine_spec.rb +0 -374
- data/spec/flipper/export_spec.rb +0 -13
- data/spec/flipper/exporter_spec.rb +0 -16
- data/spec/flipper/exporters/json/export_spec.rb +0 -60
- data/spec/flipper/exporters/json/v1_spec.rb +0 -33
- data/spec/flipper/expression/builder_spec.rb +0 -248
- data/spec/flipper/expression_spec.rb +0 -188
- data/spec/flipper/expressions/all_spec.rb +0 -15
- data/spec/flipper/expressions/any_spec.rb +0 -15
- data/spec/flipper/expressions/boolean_spec.rb +0 -15
- data/spec/flipper/expressions/equal_spec.rb +0 -24
- data/spec/flipper/expressions/greater_than_or_equal_to_spec.rb +0 -28
- data/spec/flipper/expressions/greater_than_spec.rb +0 -28
- data/spec/flipper/expressions/less_than_or_equal_to_spec.rb +0 -28
- data/spec/flipper/expressions/less_than_spec.rb +0 -32
- data/spec/flipper/expressions/not_equal_spec.rb +0 -15
- data/spec/flipper/expressions/now_spec.rb +0 -11
- data/spec/flipper/expressions/number_spec.rb +0 -21
- data/spec/flipper/expressions/percentage_of_actors_spec.rb +0 -20
- data/spec/flipper/expressions/percentage_spec.rb +0 -15
- data/spec/flipper/expressions/property_spec.rb +0 -13
- data/spec/flipper/expressions/random_spec.rb +0 -9
- data/spec/flipper/expressions/string_spec.rb +0 -11
- data/spec/flipper/expressions/time_spec.rb +0 -29
- data/spec/flipper/feature_check_context_spec.rb +0 -65
- data/spec/flipper/feature_spec.rb +0 -1227
- data/spec/flipper/gate_spec.rb +0 -39
- data/spec/flipper/gate_values_spec.rb +0 -103
- data/spec/flipper/gates/actor_spec.rb +0 -7
- data/spec/flipper/gates/boolean_spec.rb +0 -74
- data/spec/flipper/gates/expression_spec.rb +0 -190
- data/spec/flipper/gates/group_spec.rb +0 -62
- data/spec/flipper/gates/percentage_of_actors_spec.rb +0 -131
- data/spec/flipper/gates/percentage_of_time_spec.rb +0 -37
- data/spec/flipper/identifier_spec.rb +0 -12
- data/spec/flipper/instrumentation/log_subscriber_spec.rb +0 -122
- data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +0 -95
- data/spec/flipper/instrumenters/memory_spec.rb +0 -43
- data/spec/flipper/instrumenters/noop_spec.rb +0 -27
- data/spec/flipper/middleware/memoizer_spec.rb +0 -518
- data/spec/flipper/middleware/setup_env_spec.rb +0 -94
- data/spec/flipper/model/active_record_spec.rb +0 -72
- data/spec/flipper/poller_spec.rb +0 -390
- data/spec/flipper/registry_spec.rb +0 -140
- data/spec/flipper/serializers/gzip_spec.rb +0 -13
- data/spec/flipper/serializers/json_spec.rb +0 -13
- data/spec/flipper/typecast_spec.rb +0 -232
- data/spec/flipper/types/actor_spec.rb +0 -132
- data/spec/flipper/types/boolean_spec.rb +0 -23
- data/spec/flipper/types/group_spec.rb +0 -112
- data/spec/flipper/types/percentage_of_actors_spec.rb +0 -5
- data/spec/flipper/types/percentage_of_time_spec.rb +0 -5
- data/spec/flipper/types/percentage_spec.rb +0 -46
- data/spec/flipper_integration_spec.rb +0 -783
- data/spec/flipper_spec.rb +0 -422
- data/spec/spec_helper.rb +0 -112
- data/spec/support/actor_names.yml +0 -1
- data/spec/support/descriptions.yml +0 -1
- data/spec/support/fail_on_output.rb +0 -8
- data/spec/support/fake_backoff_policy.rb +0 -15
- data/spec/support/fake_udp_socket.rb +0 -27
- data/spec/support/skippable.rb +0 -18
- data/spec/support/spec_helpers.rb +0 -111
- data/test/adapters/actor_limit_test.rb +0 -20
- data/test/adapters/memory_test.rb +0 -9
- data/test/adapters/pstore_test.rb +0 -17
- data/test/test_helper.rb +0 -7
- data/test_rails/generators/flipper/setup_generator_test.rb +0 -69
- data/test_rails/generators/flipper/update_generator_test.rb +0 -96
- data/test_rails/helper.rb +0 -31
- data/test_rails/system/test_help_test.rb +0 -52
|
@@ -1,1227 +0,0 @@
|
|
|
1
|
-
require 'flipper/feature'
|
|
2
|
-
require 'flipper/instrumenters/memory'
|
|
3
|
-
|
|
4
|
-
RSpec.describe Flipper::Feature do
|
|
5
|
-
subject { described_class.new(:search, adapter) }
|
|
6
|
-
|
|
7
|
-
let(:adapter) { Flipper::Adapters::Memory.new }
|
|
8
|
-
|
|
9
|
-
describe '#initialize' do
|
|
10
|
-
it 'sets name' do
|
|
11
|
-
feature = described_class.new(:search, adapter)
|
|
12
|
-
expect(feature.name).to eq(:search)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'sets adapter' do
|
|
16
|
-
feature = described_class.new(:search, adapter)
|
|
17
|
-
expect(feature.adapter).to eq(adapter)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'defaults instrumenter' do
|
|
21
|
-
feature = described_class.new(:search, adapter)
|
|
22
|
-
expect(feature.instrumenter).to be(Flipper::Instrumenters::Noop)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'with overriden instrumenter' do
|
|
26
|
-
let(:instrumenter) { double('Instrumentor', instrument: nil) }
|
|
27
|
-
|
|
28
|
-
it 'overrides default instrumenter' do
|
|
29
|
-
feature = described_class.new(:search, adapter, instrumenter: instrumenter)
|
|
30
|
-
expect(feature.instrumenter).to be(instrumenter)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe "#enabled?" do
|
|
36
|
-
context "for an actor" do
|
|
37
|
-
let(:actor) { Flipper::Actor.new("User;1") }
|
|
38
|
-
|
|
39
|
-
it 'returns true if feature is enabled' do
|
|
40
|
-
subject.enable
|
|
41
|
-
expect(subject.enabled?(actor)).to be(true)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'returns false if feature is disabled' do
|
|
45
|
-
subject.disable
|
|
46
|
-
expect(subject.enabled?(actor)).to be(false)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "for multiple actors" do
|
|
51
|
-
let(:actors) {
|
|
52
|
-
[
|
|
53
|
-
Flipper::Actor.new("User;1"),
|
|
54
|
-
Flipper::Actor.new("User;2"),
|
|
55
|
-
Flipper::Actor.new("User;3"),
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
it 'returns true if feature is enabled' do
|
|
60
|
-
subject.enable
|
|
61
|
-
expect(subject.enabled?(actors)).to be(true)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it 'returns true if feature is enabled for any actor' do
|
|
65
|
-
subject.enable_actor actors.first
|
|
66
|
-
expect(subject.enabled?(actors)).to be(true)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'returns true if feature is enabled for any actor with multiple arguments' do
|
|
70
|
-
subject.enable_actor actors.last
|
|
71
|
-
expect(subject.enabled?(*actors)).to be(true)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'returns false if feature is disabled for all actors' do
|
|
75
|
-
subject.disable
|
|
76
|
-
expect(subject.enabled?(actors)).to be(false)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "for an object that implements .nil? == true" do
|
|
81
|
-
let(:actor) { Flipper::Actor.new("User;1") }
|
|
82
|
-
|
|
83
|
-
before do
|
|
84
|
-
def actor.nil?
|
|
85
|
-
true
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'returns true if feature is enabled' do
|
|
90
|
-
subject.enable
|
|
91
|
-
expect(subject.enabled?(actor)).to be(true)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it 'returns false if feature is disabled' do
|
|
95
|
-
subject.disable
|
|
96
|
-
expect(subject.enabled?(actor)).to be(false)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe '#to_s' do
|
|
102
|
-
it 'returns name as string' do
|
|
103
|
-
feature = described_class.new(:search, adapter)
|
|
104
|
-
expect(feature.to_s).to eq('search')
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
describe '#to_param' do
|
|
109
|
-
it 'returns name as string' do
|
|
110
|
-
feature = described_class.new(:search, adapter)
|
|
111
|
-
expect(feature.to_param).to eq('search')
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
describe '#gate_for' do
|
|
116
|
-
context 'with percentage of actors' do
|
|
117
|
-
it 'returns percentage of actors gate' do
|
|
118
|
-
percentage = Flipper::Types::PercentageOfActors.new(10)
|
|
119
|
-
gate = subject.gate_for(percentage)
|
|
120
|
-
expect(gate).to be_instance_of(Flipper::Gates::PercentageOfActors)
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
describe '#gates' do
|
|
126
|
-
it 'returns array of gates' do
|
|
127
|
-
instance = described_class.new(:search, adapter)
|
|
128
|
-
expect(instance.gates).to be_instance_of(Array)
|
|
129
|
-
instance.gates.each do |gate|
|
|
130
|
-
expect(gate).to be_a(Flipper::Gate)
|
|
131
|
-
end
|
|
132
|
-
expect(instance.gates.size).to be(6)
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
describe '#gate' do
|
|
137
|
-
context 'with symbol name' do
|
|
138
|
-
it 'returns gate by name' do
|
|
139
|
-
expect(subject.gate(:boolean)).to be_instance_of(Flipper::Gates::Boolean)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
context 'with string name' do
|
|
144
|
-
it 'returns gate by name' do
|
|
145
|
-
expect(subject.gate('boolean')).to be_instance_of(Flipper::Gates::Boolean)
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
context 'with name that does not exist' do
|
|
150
|
-
it 'returns nil' do
|
|
151
|
-
expect(subject.gate(:poo)).to be_nil
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
describe '#add' do
|
|
157
|
-
it 'adds feature to adapter' do
|
|
158
|
-
expect(adapter.features).to eq(Set.new)
|
|
159
|
-
subject.add
|
|
160
|
-
expect(adapter.features).to eq(Set[subject.key])
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
describe '#exist?' do
|
|
165
|
-
it 'returns true if feature is added in adapter' do
|
|
166
|
-
subject.add
|
|
167
|
-
expect(subject.exist?).to be(true)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it 'returns false if feature is NOT added in adapter' do
|
|
171
|
-
expect(subject.exist?).to be(false)
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
describe '#remove' do
|
|
176
|
-
it 'removes feature from adapter' do
|
|
177
|
-
adapter.add(subject)
|
|
178
|
-
expect(adapter.features).to eq(Set[subject.key])
|
|
179
|
-
subject.remove
|
|
180
|
-
expect(adapter.features).to eq(Set.new)
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
describe '#clear' do
|
|
185
|
-
it 'clears feature using adapter' do
|
|
186
|
-
subject.enable
|
|
187
|
-
expect(subject).to be_enabled
|
|
188
|
-
subject.clear
|
|
189
|
-
expect(subject).not_to be_enabled
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
describe '#inspect' do
|
|
194
|
-
it 'returns easy to read string representation' do
|
|
195
|
-
string = subject.inspect
|
|
196
|
-
expect(string).to include('Flipper::Feature')
|
|
197
|
-
expect(string).to include('name=:search')
|
|
198
|
-
expect(string).to include('state=:off')
|
|
199
|
-
expect(string).to include('enabled_gate_names=[]')
|
|
200
|
-
expect(string).to include("adapter=#{subject.adapter.name.inspect}")
|
|
201
|
-
|
|
202
|
-
subject.enable
|
|
203
|
-
string = subject.inspect
|
|
204
|
-
expect(string).to include('state=:on')
|
|
205
|
-
expect(string).to include('enabled_gate_names=[:boolean]')
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
describe 'instrumentation' do
|
|
210
|
-
let(:instrumenter) { Flipper::Instrumenters::Memory.new }
|
|
211
|
-
|
|
212
|
-
subject do
|
|
213
|
-
described_class.new(:search, adapter, instrumenter: instrumenter)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it 'is recorded for enable' do
|
|
217
|
-
actor = Flipper::Types::Actor.new(Flipper::Actor.new('1'))
|
|
218
|
-
subject.gate_for(actor)
|
|
219
|
-
|
|
220
|
-
subject.enable(actor)
|
|
221
|
-
|
|
222
|
-
event = instrumenter.events.last
|
|
223
|
-
expect(event).not_to be_nil
|
|
224
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
225
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
226
|
-
expect(event.payload[:operation]).to eq(:enable)
|
|
227
|
-
expect(event.payload[:thing]).to eq(actor)
|
|
228
|
-
expect(event.payload[:result]).not_to be_nil
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
it 'always instruments flipper type instance for enable' do
|
|
232
|
-
actor = Flipper::Actor.new('1')
|
|
233
|
-
subject.gate_for(actor)
|
|
234
|
-
|
|
235
|
-
subject.enable(actor)
|
|
236
|
-
|
|
237
|
-
event = instrumenter.events.last
|
|
238
|
-
expect(event).not_to be_nil
|
|
239
|
-
expect(event.payload[:thing]).to eq(Flipper::Types::Actor.new(actor))
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it 'is recorded for disable' do
|
|
243
|
-
thing = Flipper::Types::Boolean.new
|
|
244
|
-
|
|
245
|
-
subject.disable(thing)
|
|
246
|
-
|
|
247
|
-
event = instrumenter.events.last
|
|
248
|
-
expect(event).not_to be_nil
|
|
249
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
250
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
251
|
-
expect(event.payload[:operation]).to eq(:disable)
|
|
252
|
-
expect(event.payload[:thing]).to eq(thing)
|
|
253
|
-
expect(event.payload[:result]).not_to be_nil
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
user = Flipper::Actor.new('1')
|
|
257
|
-
actor = Flipper::Types::Actor.new(user)
|
|
258
|
-
boolean_true = Flipper::Types::Boolean.new(true)
|
|
259
|
-
boolean_false = Flipper::Types::Boolean.new(false)
|
|
260
|
-
group = Flipper::Types::Group.new(:admins)
|
|
261
|
-
percentage_of_time = Flipper::Types::PercentageOfTime.new(10)
|
|
262
|
-
percentage_of_actors = Flipper::Types::PercentageOfActors.new(10)
|
|
263
|
-
{
|
|
264
|
-
user => actor,
|
|
265
|
-
actor => actor,
|
|
266
|
-
true => boolean_true,
|
|
267
|
-
false => boolean_false,
|
|
268
|
-
boolean_true => boolean_true,
|
|
269
|
-
boolean_false => boolean_false,
|
|
270
|
-
:admins => group,
|
|
271
|
-
group => group,
|
|
272
|
-
percentage_of_time => percentage_of_time,
|
|
273
|
-
percentage_of_actors => percentage_of_actors,
|
|
274
|
-
}.each do |thing, wrapped_thing|
|
|
275
|
-
it "always instruments #{thing.inspect} as #{wrapped_thing.class} for enable" do
|
|
276
|
-
Flipper.register(:admins) {}
|
|
277
|
-
subject.enable(thing)
|
|
278
|
-
|
|
279
|
-
event = instrumenter.events.last
|
|
280
|
-
expect(event).not_to be_nil
|
|
281
|
-
expect(event.payload[:operation]).to eq(:enable)
|
|
282
|
-
expect(event.payload[:thing]).to eq(wrapped_thing)
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
it 'always instruments flipper type instance for disable' do
|
|
287
|
-
actor = Flipper::Actor.new('1')
|
|
288
|
-
|
|
289
|
-
subject.disable(actor)
|
|
290
|
-
|
|
291
|
-
event = instrumenter.events.last
|
|
292
|
-
expect(event).not_to be_nil
|
|
293
|
-
expect(event.payload[:operation]).to eq(:disable)
|
|
294
|
-
expect(event.payload[:thing]).to eq(Flipper::Types::Actor.new(actor))
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
it 'is recorded for add' do
|
|
298
|
-
subject.add
|
|
299
|
-
|
|
300
|
-
event = instrumenter.events.last
|
|
301
|
-
expect(event).not_to be_nil
|
|
302
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
303
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
304
|
-
expect(event.payload[:operation]).to eq(:add)
|
|
305
|
-
expect(event.payload[:result]).not_to be_nil
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
it 'is recorded for exist?' do
|
|
309
|
-
subject.exist?
|
|
310
|
-
|
|
311
|
-
event = instrumenter.events.last
|
|
312
|
-
expect(event).not_to be_nil
|
|
313
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
314
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
315
|
-
expect(event.payload[:operation]).to eq(:exist?)
|
|
316
|
-
expect(event.payload[:result]).not_to be_nil
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
it 'is recorded for remove' do
|
|
320
|
-
subject.remove
|
|
321
|
-
|
|
322
|
-
event = instrumenter.events.last
|
|
323
|
-
expect(event).not_to be_nil
|
|
324
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
325
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
326
|
-
expect(event.payload[:operation]).to eq(:remove)
|
|
327
|
-
expect(event.payload[:result]).not_to be_nil
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
it 'is recorded for clear' do
|
|
331
|
-
subject.clear
|
|
332
|
-
|
|
333
|
-
event = instrumenter.events.last
|
|
334
|
-
expect(event).not_to be_nil
|
|
335
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
336
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
337
|
-
expect(event.payload[:operation]).to eq(:clear)
|
|
338
|
-
expect(event.payload[:result]).not_to be_nil
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
it 'is recorded for enabled?' do
|
|
342
|
-
actor = Flipper::Types::Actor.new(Flipper::Actor.new('1'))
|
|
343
|
-
subject.enabled?(actor)
|
|
344
|
-
|
|
345
|
-
event = instrumenter.events.last
|
|
346
|
-
expect(event).not_to be_nil
|
|
347
|
-
expect(event.name).to eq('feature_operation.flipper')
|
|
348
|
-
expect(event.payload[:feature_name]).to eq(:search)
|
|
349
|
-
expect(event.payload[:operation]).to eq(:enabled?)
|
|
350
|
-
expect(event.payload[:actors]).to eq([actor])
|
|
351
|
-
expect(event.payload[:result]).to eq(false)
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
user = Flipper::Actor.new('1')
|
|
355
|
-
actor = Flipper::Types::Actor.new(user)
|
|
356
|
-
{
|
|
357
|
-
nil => nil,
|
|
358
|
-
user => [actor],
|
|
359
|
-
actor => [actor],
|
|
360
|
-
}.each do |thing, wrapped_thing|
|
|
361
|
-
it "always instruments #{thing.inspect} as #{wrapped_thing.class} for enabled?" do
|
|
362
|
-
subject.enabled?(thing)
|
|
363
|
-
|
|
364
|
-
event = instrumenter.events.last
|
|
365
|
-
expect(event).not_to be_nil
|
|
366
|
-
expect(event.payload[:operation]).to eq(:enabled?)
|
|
367
|
-
expect(event.payload[:actors]).to eq(wrapped_thing)
|
|
368
|
-
end
|
|
369
|
-
end
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
describe '#state' do
|
|
373
|
-
context 'fully on' do
|
|
374
|
-
before do
|
|
375
|
-
subject.enable
|
|
376
|
-
end
|
|
377
|
-
|
|
378
|
-
it 'returns :on' do
|
|
379
|
-
expect(subject.state).to be(:on)
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
it 'returns true for on?' do
|
|
383
|
-
expect(subject.on?).to be(true)
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
it 'returns false for off?' do
|
|
387
|
-
expect(subject.off?).to be(false)
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
it 'returns false for conditional?' do
|
|
391
|
-
expect(subject.conditional?).to be(false)
|
|
392
|
-
end
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
context 'percentage of time set to 100' do
|
|
396
|
-
before do
|
|
397
|
-
subject.enable_percentage_of_time 100
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
it 'returns :on' do
|
|
401
|
-
expect(subject.state).to be(:on)
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
it 'returns true for on?' do
|
|
405
|
-
expect(subject.on?).to be(true)
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
it 'returns false for off?' do
|
|
409
|
-
expect(subject.off?).to be(false)
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
it 'returns false for conditional?' do
|
|
413
|
-
expect(subject.conditional?).to be(false)
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
context 'percentage of actors set to 100' do
|
|
418
|
-
before do
|
|
419
|
-
subject.enable_percentage_of_actors 100
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
it 'returns :on' do
|
|
423
|
-
expect(subject.state).to be(:conditional)
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
it 'returns false for on?' do
|
|
427
|
-
expect(subject.on?).to be(false)
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
it 'returns false for off?' do
|
|
431
|
-
expect(subject.off?).to be(false)
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
it 'returns true for conditional?' do
|
|
435
|
-
expect(subject.conditional?).to be(true)
|
|
436
|
-
end
|
|
437
|
-
end
|
|
438
|
-
|
|
439
|
-
context 'fully off' do
|
|
440
|
-
before do
|
|
441
|
-
subject.disable
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
it 'returns :off' do
|
|
445
|
-
expect(subject.state).to be(:off)
|
|
446
|
-
end
|
|
447
|
-
|
|
448
|
-
it 'returns false for on?' do
|
|
449
|
-
expect(subject.on?).to be(false)
|
|
450
|
-
end
|
|
451
|
-
|
|
452
|
-
it 'returns true for off?' do
|
|
453
|
-
expect(subject.off?).to be(true)
|
|
454
|
-
end
|
|
455
|
-
|
|
456
|
-
it 'returns false for conditional?' do
|
|
457
|
-
expect(subject.conditional?).to be(false)
|
|
458
|
-
end
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
context 'partially on' do
|
|
462
|
-
before do
|
|
463
|
-
subject.enable Flipper::Types::PercentageOfTime.new(5)
|
|
464
|
-
end
|
|
465
|
-
|
|
466
|
-
it 'returns :conditional' do
|
|
467
|
-
expect(subject.state).to be(:conditional)
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
it 'returns false for on?' do
|
|
471
|
-
expect(subject.on?).to be(false)
|
|
472
|
-
end
|
|
473
|
-
|
|
474
|
-
it 'returns false for off?' do
|
|
475
|
-
expect(subject.off?).to be(false)
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
it 'returns true for conditional?' do
|
|
479
|
-
expect(subject.conditional?).to be(true)
|
|
480
|
-
end
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
|
|
484
|
-
describe '#enabled_groups' do
|
|
485
|
-
context 'when no groups enabled' do
|
|
486
|
-
it 'returns empty set' do
|
|
487
|
-
expect(subject.enabled_groups).to eq(Set.new)
|
|
488
|
-
end
|
|
489
|
-
end
|
|
490
|
-
|
|
491
|
-
context 'when one or more groups enabled' do
|
|
492
|
-
before do
|
|
493
|
-
@staff = Flipper.register(:staff) { |actor| true }
|
|
494
|
-
@preview_features = Flipper.register(:preview_features) { |actor| true }
|
|
495
|
-
@not_enabled = Flipper.register(:not_enabled) { |actor| true }
|
|
496
|
-
@disabled = Flipper.register(:disabled) { |actor| true }
|
|
497
|
-
subject.enable @staff
|
|
498
|
-
subject.enable @preview_features
|
|
499
|
-
subject.disable @disabled
|
|
500
|
-
end
|
|
501
|
-
|
|
502
|
-
it 'returns set of enabled groups' do
|
|
503
|
-
expect(subject.enabled_groups).to eq(Set.new([
|
|
504
|
-
@staff,
|
|
505
|
-
@preview_features,
|
|
506
|
-
]))
|
|
507
|
-
end
|
|
508
|
-
|
|
509
|
-
it 'does not include groups that have not been enabled' do
|
|
510
|
-
expect(subject.enabled_groups).not_to include(@not_enabled)
|
|
511
|
-
end
|
|
512
|
-
|
|
513
|
-
it 'does not include disabled groups' do
|
|
514
|
-
expect(subject.enabled_groups).not_to include(@disabled)
|
|
515
|
-
end
|
|
516
|
-
|
|
517
|
-
it 'is aliased to groups' do
|
|
518
|
-
expect(subject.enabled_groups).to eq(subject.groups)
|
|
519
|
-
end
|
|
520
|
-
end
|
|
521
|
-
end
|
|
522
|
-
|
|
523
|
-
describe '#disabled_groups' do
|
|
524
|
-
context 'when no groups enabled' do
|
|
525
|
-
it 'returns empty set' do
|
|
526
|
-
expect(subject.disabled_groups).to eq(Set.new)
|
|
527
|
-
end
|
|
528
|
-
end
|
|
529
|
-
|
|
530
|
-
context 'when one or more groups enabled' do
|
|
531
|
-
before do
|
|
532
|
-
@staff = Flipper.register(:staff) { |actor| true }
|
|
533
|
-
@preview_features = Flipper.register(:preview_features) { |actor| true }
|
|
534
|
-
@not_enabled = Flipper.register(:not_enabled) { |actor| true }
|
|
535
|
-
@disabled = Flipper.register(:disabled) { |actor| true }
|
|
536
|
-
subject.enable @staff
|
|
537
|
-
subject.enable @preview_features
|
|
538
|
-
subject.disable @disabled
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
it 'returns set of groups that are not enabled' do
|
|
542
|
-
expect(subject.disabled_groups).to eq(Set[
|
|
543
|
-
@not_enabled,
|
|
544
|
-
@disabled,
|
|
545
|
-
])
|
|
546
|
-
end
|
|
547
|
-
end
|
|
548
|
-
end
|
|
549
|
-
|
|
550
|
-
describe '#groups_value' do
|
|
551
|
-
context 'when no groups enabled' do
|
|
552
|
-
it 'returns empty set' do
|
|
553
|
-
expect(subject.groups_value).to eq(Set.new)
|
|
554
|
-
end
|
|
555
|
-
end
|
|
556
|
-
|
|
557
|
-
context 'when one or more groups enabled' do
|
|
558
|
-
before do
|
|
559
|
-
@staff = Flipper.register(:staff) { |actor| true }
|
|
560
|
-
@preview_features = Flipper.register(:preview_features) { |actor| true }
|
|
561
|
-
@not_enabled = Flipper.register(:not_enabled) { |actor| true }
|
|
562
|
-
@disabled = Flipper.register(:disabled) { |actor| true }
|
|
563
|
-
subject.enable @staff
|
|
564
|
-
subject.enable @preview_features
|
|
565
|
-
subject.disable @disabled
|
|
566
|
-
end
|
|
567
|
-
|
|
568
|
-
it 'returns set of enabled groups' do
|
|
569
|
-
expect(subject.groups_value).to eq(Set.new([
|
|
570
|
-
@staff.name.to_s,
|
|
571
|
-
@preview_features.name.to_s,
|
|
572
|
-
]))
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
it 'does not include groups that have not been enabled' do
|
|
576
|
-
expect(subject.groups_value).not_to include(@not_enabled.name.to_s)
|
|
577
|
-
end
|
|
578
|
-
|
|
579
|
-
it 'does not include disabled groups' do
|
|
580
|
-
expect(subject.groups_value).not_to include(@disabled.name.to_s)
|
|
581
|
-
end
|
|
582
|
-
end
|
|
583
|
-
end
|
|
584
|
-
|
|
585
|
-
describe '#actors_value' do
|
|
586
|
-
context 'when no groups enabled' do
|
|
587
|
-
it 'returns empty set' do
|
|
588
|
-
expect(subject.actors_value).to eq(Set.new)
|
|
589
|
-
end
|
|
590
|
-
end
|
|
591
|
-
|
|
592
|
-
context 'when one or more actors are enabled' do
|
|
593
|
-
before do
|
|
594
|
-
subject.enable Flipper::Types::Actor.new(Flipper::Actor.new('User;5'))
|
|
595
|
-
subject.enable Flipper::Types::Actor.new(Flipper::Actor.new('User;22'))
|
|
596
|
-
end
|
|
597
|
-
|
|
598
|
-
it 'returns set of actor ids' do
|
|
599
|
-
expect(subject.actors_value).to eq(Set.new(['User;5', 'User;22']))
|
|
600
|
-
end
|
|
601
|
-
end
|
|
602
|
-
end
|
|
603
|
-
|
|
604
|
-
describe '#boolean_value' do
|
|
605
|
-
context 'when not enabled or disabled' do
|
|
606
|
-
it 'returns false' do
|
|
607
|
-
expect(subject.boolean_value).to be(false)
|
|
608
|
-
end
|
|
609
|
-
end
|
|
610
|
-
|
|
611
|
-
context 'when enabled' do
|
|
612
|
-
before do
|
|
613
|
-
subject.enable
|
|
614
|
-
end
|
|
615
|
-
|
|
616
|
-
it 'returns true' do
|
|
617
|
-
expect(subject.boolean_value).to be(true)
|
|
618
|
-
end
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
context 'when disabled' do
|
|
622
|
-
before do
|
|
623
|
-
subject.disable
|
|
624
|
-
end
|
|
625
|
-
|
|
626
|
-
it 'returns false' do
|
|
627
|
-
expect(subject.boolean_value).to be(false)
|
|
628
|
-
end
|
|
629
|
-
end
|
|
630
|
-
end
|
|
631
|
-
|
|
632
|
-
describe '#percentage_of_actors_value' do
|
|
633
|
-
context 'when not enabled or disabled' do
|
|
634
|
-
it 'returns nil' do
|
|
635
|
-
expect(subject.percentage_of_actors_value).to be(0)
|
|
636
|
-
end
|
|
637
|
-
end
|
|
638
|
-
|
|
639
|
-
context 'when enabled' do
|
|
640
|
-
before do
|
|
641
|
-
subject.enable Flipper::Types::PercentageOfActors.new(5)
|
|
642
|
-
end
|
|
643
|
-
|
|
644
|
-
it 'returns true' do
|
|
645
|
-
expect(subject.percentage_of_actors_value).to eq(5)
|
|
646
|
-
end
|
|
647
|
-
end
|
|
648
|
-
|
|
649
|
-
context 'when disabled' do
|
|
650
|
-
before do
|
|
651
|
-
subject.disable
|
|
652
|
-
end
|
|
653
|
-
|
|
654
|
-
it 'returns nil' do
|
|
655
|
-
expect(subject.percentage_of_actors_value).to be(0)
|
|
656
|
-
end
|
|
657
|
-
end
|
|
658
|
-
end
|
|
659
|
-
|
|
660
|
-
describe '#percentage_of_time_value' do
|
|
661
|
-
context 'when not enabled or disabled' do
|
|
662
|
-
it 'returns nil' do
|
|
663
|
-
expect(subject.percentage_of_time_value).to be(0)
|
|
664
|
-
end
|
|
665
|
-
end
|
|
666
|
-
|
|
667
|
-
context 'when enabled' do
|
|
668
|
-
before do
|
|
669
|
-
subject.enable Flipper::Types::PercentageOfTime.new(5)
|
|
670
|
-
end
|
|
671
|
-
|
|
672
|
-
it 'returns true' do
|
|
673
|
-
expect(subject.percentage_of_time_value).to eq(5)
|
|
674
|
-
end
|
|
675
|
-
end
|
|
676
|
-
|
|
677
|
-
context 'when disabled' do
|
|
678
|
-
before do
|
|
679
|
-
subject.disable
|
|
680
|
-
end
|
|
681
|
-
|
|
682
|
-
it 'returns nil' do
|
|
683
|
-
expect(subject.percentage_of_time_value).to be(0)
|
|
684
|
-
end
|
|
685
|
-
end
|
|
686
|
-
end
|
|
687
|
-
|
|
688
|
-
describe '#gate_values' do
|
|
689
|
-
context 'when no gates are set in adapter' do
|
|
690
|
-
it 'returns default gate values' do
|
|
691
|
-
expect(subject.gate_values).to eq(Flipper::GateValues.new(adapter.default_config))
|
|
692
|
-
end
|
|
693
|
-
end
|
|
694
|
-
|
|
695
|
-
context 'with gate values set in adapter' do
|
|
696
|
-
before do
|
|
697
|
-
subject.enable Flipper::Types::Boolean.new(true)
|
|
698
|
-
subject.enable Flipper::Types::Actor.new(Flipper::Actor.new(5))
|
|
699
|
-
subject.enable Flipper::Types::Group.new(:admins)
|
|
700
|
-
subject.enable Flipper::Types::PercentageOfTime.new(50)
|
|
701
|
-
subject.enable Flipper::Types::PercentageOfActors.new(25)
|
|
702
|
-
end
|
|
703
|
-
|
|
704
|
-
it 'returns gate values' do
|
|
705
|
-
expect(subject.gate_values).to eq(Flipper::GateValues.new(actors: Set.new(['5']),
|
|
706
|
-
groups: Set.new(['admins']),
|
|
707
|
-
boolean: 'true',
|
|
708
|
-
percentage_of_time: '50',
|
|
709
|
-
percentage_of_actors: '25'))
|
|
710
|
-
end
|
|
711
|
-
end
|
|
712
|
-
end
|
|
713
|
-
|
|
714
|
-
describe '#expression' do
|
|
715
|
-
it "returns nil if feature has no expression" do
|
|
716
|
-
expect(subject.expression).to be(nil)
|
|
717
|
-
end
|
|
718
|
-
|
|
719
|
-
it "returns expression if feature has expression" do
|
|
720
|
-
expression = Flipper.property(:plan).eq("basic")
|
|
721
|
-
subject.enable_expression expression
|
|
722
|
-
expect(subject.expression).to eq(expression)
|
|
723
|
-
end
|
|
724
|
-
end
|
|
725
|
-
|
|
726
|
-
describe '#enable_expression/disable_expression' do
|
|
727
|
-
context "with expression instance" do
|
|
728
|
-
it "updates gate values to equal expression or clears expression" do
|
|
729
|
-
expression = Flipper.property(:plan).eq("basic")
|
|
730
|
-
expect(subject.gate_values.expression).to be(nil)
|
|
731
|
-
subject.enable_expression(expression)
|
|
732
|
-
expect(subject.gate_values.expression).to eq(expression.value)
|
|
733
|
-
subject.disable_expression
|
|
734
|
-
expect(subject.gate_values.expression).to be(nil)
|
|
735
|
-
end
|
|
736
|
-
end
|
|
737
|
-
|
|
738
|
-
context "with Hash" do
|
|
739
|
-
it "updates gate values to equal expression or clears expression" do
|
|
740
|
-
expression = Flipper.property(:plan).eq("basic")
|
|
741
|
-
expect(subject.gate_values.expression).to be(nil)
|
|
742
|
-
subject.enable_expression(expression.value)
|
|
743
|
-
expect(subject.gate_values.expression).to eq(expression.value)
|
|
744
|
-
subject.disable_expression
|
|
745
|
-
expect(subject.gate_values.expression).to be(nil)
|
|
746
|
-
end
|
|
747
|
-
end
|
|
748
|
-
end
|
|
749
|
-
|
|
750
|
-
describe "#add_expression" do
|
|
751
|
-
context "when nothing enabled" do
|
|
752
|
-
context "with Expression instance" do
|
|
753
|
-
it "sets expression to Expression" do
|
|
754
|
-
expression = Flipper.property(:plan).eq("basic")
|
|
755
|
-
subject.add_expression(expression)
|
|
756
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
757
|
-
expect(subject.expression).to eq(expression)
|
|
758
|
-
end
|
|
759
|
-
end
|
|
760
|
-
|
|
761
|
-
context "with Any instance" do
|
|
762
|
-
it "sets expression to Any" do
|
|
763
|
-
expression = Flipper.any(Flipper.property(:plan).eq("basic"))
|
|
764
|
-
subject.add_expression(expression)
|
|
765
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
766
|
-
expect(subject.expression).to eq(expression)
|
|
767
|
-
end
|
|
768
|
-
end
|
|
769
|
-
|
|
770
|
-
context "with All instance" do
|
|
771
|
-
it "sets expression to All" do
|
|
772
|
-
expression = Flipper.all(Flipper.property(:plan).eq("basic"))
|
|
773
|
-
subject.add_expression(expression)
|
|
774
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
775
|
-
expect(subject.expression).to eq(expression)
|
|
776
|
-
end
|
|
777
|
-
end
|
|
778
|
-
end
|
|
779
|
-
|
|
780
|
-
context "when Expression enabled" do
|
|
781
|
-
let(:expression) { Flipper.property(:plan).eq("basic") }
|
|
782
|
-
|
|
783
|
-
before do
|
|
784
|
-
subject.enable_expression expression
|
|
785
|
-
end
|
|
786
|
-
|
|
787
|
-
context "with Expression instance" do
|
|
788
|
-
it "changes expression to Any and adds new Expression" do
|
|
789
|
-
new_expression = Flipper.property(:age).gte(21)
|
|
790
|
-
subject.add_expression(new_expression)
|
|
791
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
792
|
-
expect(subject.expression.args).to include(expression)
|
|
793
|
-
expect(subject.expression.args).to include(new_expression)
|
|
794
|
-
end
|
|
795
|
-
end
|
|
796
|
-
|
|
797
|
-
context "with Any instance" do
|
|
798
|
-
it "changes expression to Any and adds new Any" do
|
|
799
|
-
new_expression = Flipper.any(Flipper.property(:age).eq(21))
|
|
800
|
-
subject.add_expression new_expression
|
|
801
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
802
|
-
expect(subject.expression.args).to include(expression)
|
|
803
|
-
expect(subject.expression.args).to include(new_expression)
|
|
804
|
-
end
|
|
805
|
-
end
|
|
806
|
-
|
|
807
|
-
context "with All instance" do
|
|
808
|
-
it "changes expression to Any and adds new All" do
|
|
809
|
-
new_expression = Flipper.all(Flipper.property(:plan).eq("basic"))
|
|
810
|
-
subject.add_expression new_expression
|
|
811
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
812
|
-
expect(subject.expression.args).to include(expression)
|
|
813
|
-
expect(subject.expression.args).to include(new_expression)
|
|
814
|
-
end
|
|
815
|
-
end
|
|
816
|
-
end
|
|
817
|
-
|
|
818
|
-
context "when Any enabled" do
|
|
819
|
-
let(:condition) { Flipper.property(:plan).eq("basic") }
|
|
820
|
-
let(:expression) { Flipper.any(condition) }
|
|
821
|
-
|
|
822
|
-
before do
|
|
823
|
-
subject.enable_expression expression
|
|
824
|
-
end
|
|
825
|
-
|
|
826
|
-
context "with Expression instance" do
|
|
827
|
-
it "adds Expression to Any" do
|
|
828
|
-
new_expression = Flipper.property(:age).gte(21)
|
|
829
|
-
subject.add_expression(new_expression)
|
|
830
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
831
|
-
expect(subject.expression.args).to include(condition)
|
|
832
|
-
expect(subject.expression.args).to include(new_expression)
|
|
833
|
-
end
|
|
834
|
-
end
|
|
835
|
-
|
|
836
|
-
context "with Any instance" do
|
|
837
|
-
it "adds Any to Any" do
|
|
838
|
-
new_expression = Flipper.any(Flipper.property(:age).gte(21))
|
|
839
|
-
subject.add_expression(new_expression)
|
|
840
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
841
|
-
expect(subject.expression.args).to include(condition)
|
|
842
|
-
expect(subject.expression.args).to include(new_expression)
|
|
843
|
-
end
|
|
844
|
-
end
|
|
845
|
-
|
|
846
|
-
context "with All instance" do
|
|
847
|
-
it "adds All to Any" do
|
|
848
|
-
new_expression = Flipper.all(Flipper.property(:age).gte(21))
|
|
849
|
-
subject.add_expression(new_expression)
|
|
850
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
851
|
-
expect(subject.expression.args).to include(condition)
|
|
852
|
-
expect(subject.expression.args).to include(new_expression)
|
|
853
|
-
end
|
|
854
|
-
end
|
|
855
|
-
end
|
|
856
|
-
|
|
857
|
-
context "when All enabled" do
|
|
858
|
-
let(:condition) { Flipper.property(:plan).eq("basic") }
|
|
859
|
-
let(:expression) { Flipper.all(condition) }
|
|
860
|
-
|
|
861
|
-
before do
|
|
862
|
-
subject.enable_expression expression
|
|
863
|
-
end
|
|
864
|
-
|
|
865
|
-
context "with Expression instance" do
|
|
866
|
-
it "adds Expression to All" do
|
|
867
|
-
new_expression = Flipper.property(:age).gte(21)
|
|
868
|
-
subject.add_expression(new_expression)
|
|
869
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
870
|
-
expect(subject.expression.args).to include(condition)
|
|
871
|
-
expect(subject.expression.args).to include(new_expression)
|
|
872
|
-
end
|
|
873
|
-
end
|
|
874
|
-
|
|
875
|
-
context "with Any instance" do
|
|
876
|
-
it "adds Any to All" do
|
|
877
|
-
new_expression = Flipper.any(Flipper.property(:age).gte(21))
|
|
878
|
-
subject.add_expression(new_expression)
|
|
879
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
880
|
-
expect(subject.expression.args).to include(condition)
|
|
881
|
-
expect(subject.expression.args).to include(new_expression)
|
|
882
|
-
end
|
|
883
|
-
end
|
|
884
|
-
|
|
885
|
-
context "with All instance" do
|
|
886
|
-
it "adds All to All" do
|
|
887
|
-
new_expression = Flipper.all(Flipper.property(:age).gte(21))
|
|
888
|
-
subject.add_expression(new_expression)
|
|
889
|
-
expect(subject.expression).to be_instance_of(Flipper::Expression)
|
|
890
|
-
expect(subject.expression.args).to include(condition)
|
|
891
|
-
expect(subject.expression.args).to include(new_expression)
|
|
892
|
-
end
|
|
893
|
-
end
|
|
894
|
-
end
|
|
895
|
-
end
|
|
896
|
-
|
|
897
|
-
describe '#remove_expression' do
|
|
898
|
-
context "when nothing enabled" do
|
|
899
|
-
context "with Expression instance" do
|
|
900
|
-
it "does nothing" do
|
|
901
|
-
expression = Flipper.property(:plan).eq("basic")
|
|
902
|
-
subject.remove_expression(expression)
|
|
903
|
-
expect(subject.expression).to be(nil)
|
|
904
|
-
end
|
|
905
|
-
end
|
|
906
|
-
|
|
907
|
-
context "with Any instance" do
|
|
908
|
-
it "does nothing" do
|
|
909
|
-
expression = Flipper.any(Flipper.property(:plan).eq("basic"))
|
|
910
|
-
subject.remove_expression expression
|
|
911
|
-
expect(subject.expression).to be(nil)
|
|
912
|
-
end
|
|
913
|
-
end
|
|
914
|
-
|
|
915
|
-
context "with All instance" do
|
|
916
|
-
it "does nothing" do
|
|
917
|
-
expression = Flipper.all(Flipper.property(:plan).eq("basic"))
|
|
918
|
-
subject.remove_expression expression
|
|
919
|
-
expect(subject.expression).to be(nil)
|
|
920
|
-
end
|
|
921
|
-
end
|
|
922
|
-
end
|
|
923
|
-
|
|
924
|
-
context "when Expression enabled" do
|
|
925
|
-
let(:expression) { Flipper.property(:plan).eq("basic") }
|
|
926
|
-
|
|
927
|
-
before do
|
|
928
|
-
subject.enable_expression expression
|
|
929
|
-
end
|
|
930
|
-
|
|
931
|
-
context "with Expression instance" do
|
|
932
|
-
it "changes expression to Any and removes Expression if it matches" do
|
|
933
|
-
new_expression = Flipper.property(:plan).eq("basic")
|
|
934
|
-
subject.remove_expression new_expression
|
|
935
|
-
expect(subject.expression).to eq(Flipper.any)
|
|
936
|
-
end
|
|
937
|
-
|
|
938
|
-
it "changes expression to Any if Expression doesn't match" do
|
|
939
|
-
new_expression = Flipper.property(:plan).eq("premium")
|
|
940
|
-
subject.remove_expression new_expression
|
|
941
|
-
expect(subject.expression).to eq(Flipper.any(expression))
|
|
942
|
-
end
|
|
943
|
-
end
|
|
944
|
-
|
|
945
|
-
context "with Any instance" do
|
|
946
|
-
it "changes expression to Any and does nothing" do
|
|
947
|
-
new_expression = Flipper.any(Flipper.property(:plan).eq("basic"))
|
|
948
|
-
subject.remove_expression new_expression
|
|
949
|
-
expect(subject.expression).to eq(Flipper.any(expression))
|
|
950
|
-
end
|
|
951
|
-
end
|
|
952
|
-
|
|
953
|
-
context "with All instance" do
|
|
954
|
-
it "changes expression to Any and does nothing" do
|
|
955
|
-
new_expression = Flipper.all(Flipper.property(:plan).eq("basic"))
|
|
956
|
-
subject.remove_expression new_expression
|
|
957
|
-
expect(subject.expression).to eq(Flipper.any(expression))
|
|
958
|
-
end
|
|
959
|
-
end
|
|
960
|
-
end
|
|
961
|
-
|
|
962
|
-
context "when Any enabled" do
|
|
963
|
-
let(:condition) { Flipper.property(:plan).eq("basic") }
|
|
964
|
-
let(:expression) { Flipper.any condition }
|
|
965
|
-
|
|
966
|
-
before do
|
|
967
|
-
subject.enable_expression expression
|
|
968
|
-
end
|
|
969
|
-
|
|
970
|
-
context "with Expression instance" do
|
|
971
|
-
it "removes Expression if it matches" do
|
|
972
|
-
subject.remove_expression condition
|
|
973
|
-
expect(subject.expression).to eq(Flipper.any)
|
|
974
|
-
end
|
|
975
|
-
|
|
976
|
-
it "does nothing if Expression does not match" do
|
|
977
|
-
subject.remove_expression Flipper.property(:plan).eq("premium")
|
|
978
|
-
expect(subject.expression).to eq(expression)
|
|
979
|
-
end
|
|
980
|
-
end
|
|
981
|
-
|
|
982
|
-
context "with Any instance" do
|
|
983
|
-
it "removes Any if it matches" do
|
|
984
|
-
new_expression = Flipper.any(Flipper.property(:plan).eq("premium"))
|
|
985
|
-
subject.add_expression new_expression
|
|
986
|
-
expect(subject.expression.args.size).to be(2)
|
|
987
|
-
subject.remove_expression new_expression
|
|
988
|
-
expect(subject.expression).to eq(expression)
|
|
989
|
-
end
|
|
990
|
-
|
|
991
|
-
it "does nothing if Any does not match" do
|
|
992
|
-
new_expression = Flipper.any(Flipper.property(:plan).eq("premium"))
|
|
993
|
-
subject.remove_expression new_expression
|
|
994
|
-
expect(subject.expression).to eq(expression)
|
|
995
|
-
end
|
|
996
|
-
end
|
|
997
|
-
|
|
998
|
-
context "with All instance" do
|
|
999
|
-
it "removes All if it matches" do
|
|
1000
|
-
new_expression = Flipper.all(Flipper.property(:plan).eq("premium"))
|
|
1001
|
-
subject.add_expression new_expression
|
|
1002
|
-
expect(subject.expression.args.size).to be(2)
|
|
1003
|
-
subject.remove_expression new_expression
|
|
1004
|
-
expect(subject.expression).to eq(expression)
|
|
1005
|
-
end
|
|
1006
|
-
|
|
1007
|
-
it "does nothing if All does not match" do
|
|
1008
|
-
new_expression = Flipper.all(Flipper.property(:plan).eq("premium"))
|
|
1009
|
-
subject.remove_expression new_expression
|
|
1010
|
-
expect(subject.expression).to eq(expression)
|
|
1011
|
-
end
|
|
1012
|
-
end
|
|
1013
|
-
end
|
|
1014
|
-
|
|
1015
|
-
context "when All enabled" do
|
|
1016
|
-
let(:condition) { Flipper.property(:plan).eq("basic") }
|
|
1017
|
-
let(:expression) { Flipper.all condition }
|
|
1018
|
-
|
|
1019
|
-
before do
|
|
1020
|
-
subject.enable_expression expression
|
|
1021
|
-
end
|
|
1022
|
-
|
|
1023
|
-
context "with Expression instance" do
|
|
1024
|
-
it "removes Expression if it matches" do
|
|
1025
|
-
subject.remove_expression condition
|
|
1026
|
-
expect(subject.expression).to eq(Flipper.all)
|
|
1027
|
-
end
|
|
1028
|
-
|
|
1029
|
-
it "does nothing if Expression does not match" do
|
|
1030
|
-
subject.remove_expression Flipper.property(:plan).eq("premium")
|
|
1031
|
-
expect(subject.expression).to eq(expression)
|
|
1032
|
-
end
|
|
1033
|
-
end
|
|
1034
|
-
|
|
1035
|
-
context "with Any instance" do
|
|
1036
|
-
it "removes Any if it matches" do
|
|
1037
|
-
new_expression = Flipper.any(Flipper.property(:plan).eq("premium"))
|
|
1038
|
-
subject.add_expression new_expression
|
|
1039
|
-
expect(subject.expression.args.size).to be(2)
|
|
1040
|
-
subject.remove_expression new_expression
|
|
1041
|
-
expect(subject.expression).to eq(expression)
|
|
1042
|
-
end
|
|
1043
|
-
|
|
1044
|
-
it "does nothing if Any does not match" do
|
|
1045
|
-
new_expression = Flipper.any(Flipper.property(:plan).eq("premium"))
|
|
1046
|
-
subject.remove_expression new_expression
|
|
1047
|
-
expect(subject.expression).to eq(expression)
|
|
1048
|
-
end
|
|
1049
|
-
end
|
|
1050
|
-
|
|
1051
|
-
context "with All instance" do
|
|
1052
|
-
it "removes All if it matches" do
|
|
1053
|
-
new_expression = Flipper.all(Flipper.property(:plan).eq("premium"))
|
|
1054
|
-
subject.add_expression new_expression
|
|
1055
|
-
expect(subject.expression.args.size).to be(2)
|
|
1056
|
-
subject.remove_expression new_expression
|
|
1057
|
-
expect(subject.expression).to eq(expression)
|
|
1058
|
-
end
|
|
1059
|
-
|
|
1060
|
-
it "does nothing if All does not match" do
|
|
1061
|
-
new_expression = Flipper.all(Flipper.property(:plan).eq("premium"))
|
|
1062
|
-
subject.remove_expression new_expression
|
|
1063
|
-
expect(subject.expression).to eq(expression)
|
|
1064
|
-
end
|
|
1065
|
-
end
|
|
1066
|
-
end
|
|
1067
|
-
end
|
|
1068
|
-
|
|
1069
|
-
describe '#enable_actor/disable_actor' do
|
|
1070
|
-
context 'with object that responds to flipper_id' do
|
|
1071
|
-
it 'updates the gate values to include the actor' do
|
|
1072
|
-
actor = Flipper::Actor.new(5)
|
|
1073
|
-
expect(subject.gate_values.actors).to be_empty
|
|
1074
|
-
subject.enable_actor(actor)
|
|
1075
|
-
expect(subject.gate_values.actors).to eq(Set['5'])
|
|
1076
|
-
subject.disable_actor(actor)
|
|
1077
|
-
expect(subject.gate_values.actors).to be_empty
|
|
1078
|
-
end
|
|
1079
|
-
end
|
|
1080
|
-
|
|
1081
|
-
context 'with actor instance' do
|
|
1082
|
-
it 'updates the gate values to include the actor' do
|
|
1083
|
-
actor = Flipper::Actor.new(5)
|
|
1084
|
-
instance = Flipper::Types::Actor.new(actor)
|
|
1085
|
-
expect(subject.gate_values.actors).to be_empty
|
|
1086
|
-
subject.enable_actor(instance)
|
|
1087
|
-
expect(subject.gate_values.actors).to eq(Set['5'])
|
|
1088
|
-
subject.disable_actor(instance)
|
|
1089
|
-
expect(subject.gate_values.actors).to be_empty
|
|
1090
|
-
end
|
|
1091
|
-
end
|
|
1092
|
-
end
|
|
1093
|
-
|
|
1094
|
-
describe '#enable_group/disable_group' do
|
|
1095
|
-
context 'with symbol group name' do
|
|
1096
|
-
it 'updates the gate values to include the group' do
|
|
1097
|
-
expect(subject.gate_values.groups).to be_empty
|
|
1098
|
-
subject.enable_group(:five_only)
|
|
1099
|
-
expect(subject.gate_values.groups).to eq(Set['five_only'])
|
|
1100
|
-
subject.disable_group(:five_only)
|
|
1101
|
-
expect(subject.gate_values.groups).to be_empty
|
|
1102
|
-
end
|
|
1103
|
-
end
|
|
1104
|
-
|
|
1105
|
-
context 'with string group name' do
|
|
1106
|
-
it 'updates the gate values to include the group' do
|
|
1107
|
-
expect(subject.gate_values.groups).to be_empty
|
|
1108
|
-
subject.enable_group('five_only')
|
|
1109
|
-
expect(subject.gate_values.groups).to eq(Set['five_only'])
|
|
1110
|
-
subject.disable_group('five_only')
|
|
1111
|
-
expect(subject.gate_values.groups).to be_empty
|
|
1112
|
-
end
|
|
1113
|
-
end
|
|
1114
|
-
|
|
1115
|
-
context 'with group instance' do
|
|
1116
|
-
it 'updates the gate values for the group' do
|
|
1117
|
-
group = Flipper.register(:five_only) { |actor| actor.flipper_id == 5 }
|
|
1118
|
-
expect(subject.gate_values.groups).to be_empty
|
|
1119
|
-
subject.enable_group(group)
|
|
1120
|
-
expect(subject.gate_values.groups).to eq(Set['five_only'])
|
|
1121
|
-
subject.disable_group(group)
|
|
1122
|
-
expect(subject.gate_values.groups).to be_empty
|
|
1123
|
-
end
|
|
1124
|
-
end
|
|
1125
|
-
end
|
|
1126
|
-
|
|
1127
|
-
describe '#enable_percentage_of_time/disable_percentage_of_time' do
|
|
1128
|
-
context 'with integer' do
|
|
1129
|
-
it 'updates the gate values' do
|
|
1130
|
-
expect(subject.gate_values.percentage_of_time).to be(0)
|
|
1131
|
-
subject.enable_percentage_of_time(56)
|
|
1132
|
-
expect(subject.gate_values.percentage_of_time).to be(56)
|
|
1133
|
-
subject.disable_percentage_of_time
|
|
1134
|
-
expect(subject.gate_values.percentage_of_time).to be(0)
|
|
1135
|
-
end
|
|
1136
|
-
end
|
|
1137
|
-
|
|
1138
|
-
context 'with string' do
|
|
1139
|
-
it 'updates the gate values' do
|
|
1140
|
-
expect(subject.gate_values.percentage_of_time).to be(0)
|
|
1141
|
-
subject.enable_percentage_of_time('56')
|
|
1142
|
-
expect(subject.gate_values.percentage_of_time).to be(56)
|
|
1143
|
-
subject.disable_percentage_of_time
|
|
1144
|
-
expect(subject.gate_values.percentage_of_time).to be(0)
|
|
1145
|
-
end
|
|
1146
|
-
end
|
|
1147
|
-
|
|
1148
|
-
context 'with percentage of time instance' do
|
|
1149
|
-
it 'updates the gate values' do
|
|
1150
|
-
percentage = Flipper::Types::PercentageOfTime.new(56)
|
|
1151
|
-
expect(subject.gate_values.percentage_of_time).to be(0)
|
|
1152
|
-
subject.enable_percentage_of_time(percentage)
|
|
1153
|
-
expect(subject.gate_values.percentage_of_time).to be(56)
|
|
1154
|
-
subject.disable_percentage_of_time
|
|
1155
|
-
expect(subject.gate_values.percentage_of_time).to be(0)
|
|
1156
|
-
end
|
|
1157
|
-
end
|
|
1158
|
-
end
|
|
1159
|
-
|
|
1160
|
-
describe '#enable_percentage_of_actors/disable_percentage_of_actors' do
|
|
1161
|
-
context 'with integer' do
|
|
1162
|
-
it 'updates the gate values' do
|
|
1163
|
-
expect(subject.gate_values.percentage_of_actors).to be(0)
|
|
1164
|
-
subject.enable_percentage_of_actors(56)
|
|
1165
|
-
expect(subject.gate_values.percentage_of_actors).to be(56)
|
|
1166
|
-
subject.disable_percentage_of_actors
|
|
1167
|
-
expect(subject.gate_values.percentage_of_actors).to be(0)
|
|
1168
|
-
end
|
|
1169
|
-
end
|
|
1170
|
-
|
|
1171
|
-
context 'with string' do
|
|
1172
|
-
it 'updates the gate values' do
|
|
1173
|
-
expect(subject.gate_values.percentage_of_actors).to be(0)
|
|
1174
|
-
subject.enable_percentage_of_actors('56')
|
|
1175
|
-
expect(subject.gate_values.percentage_of_actors).to be(56)
|
|
1176
|
-
subject.disable_percentage_of_actors
|
|
1177
|
-
expect(subject.gate_values.percentage_of_actors).to be(0)
|
|
1178
|
-
end
|
|
1179
|
-
end
|
|
1180
|
-
|
|
1181
|
-
context 'with percentage of actors instance' do
|
|
1182
|
-
it 'updates the gate values' do
|
|
1183
|
-
percentage = Flipper::Types::PercentageOfActors.new(56)
|
|
1184
|
-
expect(subject.gate_values.percentage_of_actors).to be(0)
|
|
1185
|
-
subject.enable_percentage_of_actors(percentage)
|
|
1186
|
-
expect(subject.gate_values.percentage_of_actors).to be(56)
|
|
1187
|
-
subject.disable_percentage_of_actors
|
|
1188
|
-
expect(subject.gate_values.percentage_of_actors).to be(0)
|
|
1189
|
-
end
|
|
1190
|
-
end
|
|
1191
|
-
end
|
|
1192
|
-
|
|
1193
|
-
describe '#enabled/disabled_gates' do
|
|
1194
|
-
before do
|
|
1195
|
-
subject.enable_percentage_of_time 5
|
|
1196
|
-
subject.enable_percentage_of_actors 5
|
|
1197
|
-
end
|
|
1198
|
-
|
|
1199
|
-
it 'can return enabled gates' do
|
|
1200
|
-
expect(subject.enabled_gates.map(&:name).to_set).to eq(Set[
|
|
1201
|
-
:percentage_of_actors,
|
|
1202
|
-
:percentage_of_time,
|
|
1203
|
-
])
|
|
1204
|
-
|
|
1205
|
-
expect(subject.enabled_gate_names.to_set).to eq(Set[
|
|
1206
|
-
:percentage_of_actors,
|
|
1207
|
-
:percentage_of_time,
|
|
1208
|
-
])
|
|
1209
|
-
end
|
|
1210
|
-
|
|
1211
|
-
it 'can return disabled gates' do
|
|
1212
|
-
expect(subject.disabled_gates.map(&:name).to_set).to eq(Set[
|
|
1213
|
-
:actor,
|
|
1214
|
-
:boolean,
|
|
1215
|
-
:group,
|
|
1216
|
-
:expression,
|
|
1217
|
-
])
|
|
1218
|
-
|
|
1219
|
-
expect(subject.disabled_gate_names.to_set).to eq(Set[
|
|
1220
|
-
:actor,
|
|
1221
|
-
:boolean,
|
|
1222
|
-
:group,
|
|
1223
|
-
:expression,
|
|
1224
|
-
])
|
|
1225
|
-
end
|
|
1226
|
-
end
|
|
1227
|
-
end
|