flipper 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/docs/Adapters.md +2 -1
- data/examples/enabled_for_actor.rb +43 -0
- data/lib/flipper/spec/shared_adapter_specs.rb +71 -71
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/instrumented_spec.rb +44 -44
- data/spec/flipper/adapters/memoizable_spec.rb +21 -21
- data/spec/flipper/adapters/memory_spec.rb +1 -1
- data/spec/flipper/adapters/operation_logger_spec.rb +11 -11
- data/spec/flipper/adapters/pstore_spec.rb +2 -2
- data/spec/flipper/dsl_spec.rb +34 -34
- data/spec/flipper/feature_spec.rb +167 -167
- data/spec/flipper/gate_spec.rb +5 -5
- data/spec/flipper/gate_values_spec.rb +17 -17
- data/spec/flipper/gates/actor_spec.rb +1 -1
- data/spec/flipper/gates/boolean_spec.rb +13 -13
- data/spec/flipper/gates/group_spec.rb +6 -6
- data/spec/flipper/gates/percentage_of_actors_spec.rb +3 -3
- data/spec/flipper/gates/percentage_of_time_spec.rb +1 -1
- data/spec/flipper/instrumentation/log_subscriber_spec.rb +10 -10
- data/spec/flipper/instrumentation/metriks_subscriber_spec.rb +14 -14
- data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +5 -3
- data/spec/flipper/instrumenters/memory_spec.rb +4 -4
- data/spec/flipper/instrumenters/noop_spec.rb +3 -3
- data/spec/flipper/middleware/memoizer_spec.rb +8 -8
- data/spec/flipper/registry_spec.rb +17 -17
- data/spec/flipper/typecast_spec.rb +4 -4
- data/spec/flipper/types/actor_spec.rb +14 -14
- data/spec/flipper/types/boolean_spec.rb +5 -5
- data/spec/flipper/types/group_spec.rb +8 -8
- data/spec/flipper/types/percentage_of_actors_spec.rb +1 -1
- data/spec/flipper/types/percentage_of_time_spec.rb +1 -1
- data/spec/flipper/types/percentage_spec.rb +8 -8
- data/spec/flipper_spec.rb +19 -19
- data/spec/helper.rb +14 -14
- data/spec/integration_spec.rb +80 -80
- metadata +4 -3
data/spec/flipper_spec.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
describe Flipper do
|
3
|
+
RSpec.describe Flipper do
|
4
4
|
describe ".new" do
|
5
5
|
it "returns new instance of dsl" do
|
6
6
|
instance = Flipper.new(double('Adapter'))
|
7
|
-
instance.
|
7
|
+
expect(instance).to be_instance_of(Flipper::DSL)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".group_exists" do
|
12
12
|
it "returns true if the group is already created" do
|
13
13
|
group = Flipper.register('admins') { |actor| actor.admin? }
|
14
|
-
Flipper.group_exists?(:admins).
|
14
|
+
expect(Flipper.group_exists?(:admins)).to eq(true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "returns false when the group is not yet registered" do
|
18
|
-
Flipper.group_exists?(:non_existing).
|
18
|
+
expect(Flipper.group_exists?(:non_existing)).to eq(false)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe ".groups_registry" do
|
23
23
|
it "returns a registry instance" do
|
24
|
-
Flipper.groups_registry.
|
24
|
+
expect(Flipper.groups_registry).to be_instance_of(Flipper::Registry)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,7 +29,7 @@ describe Flipper do
|
|
29
29
|
it "sets groups_registry registry" do
|
30
30
|
registry = Flipper::Registry.new
|
31
31
|
Flipper.groups_registry = registry
|
32
|
-
Flipper.instance_variable_get("@groups_registry").
|
32
|
+
expect(Flipper.instance_variable_get("@groups_registry")).to eq(registry)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,14 +38,14 @@ describe Flipper do
|
|
38
38
|
registry = Flipper::Registry.new
|
39
39
|
Flipper.groups_registry = registry
|
40
40
|
group = Flipper.register(:admins) { |actor| actor.admin? }
|
41
|
-
registry.get(:admins).
|
41
|
+
expect(registry.get(:admins)).to eq(group)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "adds a group to the group_registry for string name" do
|
45
45
|
registry = Flipper::Registry.new
|
46
46
|
Flipper.groups_registry = registry
|
47
47
|
group = Flipper.register('admins') { |actor| actor.admin? }
|
48
|
-
registry.get(:admins).
|
48
|
+
expect(registry.get(:admins)).to eq(group)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "raises exception if group already registered" do
|
@@ -59,7 +59,7 @@ describe Flipper do
|
|
59
59
|
|
60
60
|
describe ".unregister_groups" do
|
61
61
|
it "clear group registry" do
|
62
|
-
Flipper.groups_registry.
|
62
|
+
expect(Flipper.groups_registry).to receive(:clear)
|
63
63
|
Flipper.unregister_groups
|
64
64
|
end
|
65
65
|
end
|
@@ -71,11 +71,11 @@ describe Flipper do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns group" do
|
74
|
-
Flipper.group(:admins).
|
74
|
+
expect(Flipper.group(:admins)).to eq(@group)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "returns group with string key" do
|
78
|
-
Flipper.group('admins').
|
78
|
+
expect(Flipper.group('admins')).to eq(@group)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -92,10 +92,10 @@ describe Flipper do
|
|
92
92
|
it "returns array of group instances" do
|
93
93
|
admins = Flipper.register(:admins) { |actor| actor.admin? }
|
94
94
|
preview_features = Flipper.register(:preview_features) { |actor| actor.preview_features? }
|
95
|
-
Flipper.groups.
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
expect(Flipper.groups).to eq(Set[
|
96
|
+
admins,
|
97
|
+
preview_features,
|
98
|
+
])
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -103,10 +103,10 @@ describe Flipper do
|
|
103
103
|
it "returns array of group names" do
|
104
104
|
Flipper.register(:admins) { |actor| actor.admin? }
|
105
105
|
Flipper.register(:preview_features) { |actor| actor.preview_features? }
|
106
|
-
Flipper.group_names.
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
expect(Flipper.group_names).to eq(Set[
|
107
|
+
:admins,
|
108
|
+
:preview_features,
|
109
|
+
])
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
data/spec/helper.rb
CHANGED
@@ -14,25 +14,25 @@ require 'flipper-ui'
|
|
14
14
|
Dir[FlipperRoot.join("spec/support/**/*.rb")].each { |f| require f }
|
15
15
|
|
16
16
|
RSpec.configure do |config|
|
17
|
-
config.before(:
|
17
|
+
config.before(:example) do
|
18
18
|
Flipper.unregister_groups
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
shared_examples_for 'a percentage' do
|
22
|
+
RSpec.shared_examples_for 'a percentage' do
|
23
23
|
it "initializes with value" do
|
24
24
|
percentage = described_class.new(12)
|
25
|
-
percentage.
|
25
|
+
expect(percentage).to be_instance_of(described_class)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "converts string values to integers when initializing" do
|
29
29
|
percentage = described_class.new('15')
|
30
|
-
percentage.value.
|
30
|
+
expect(percentage.value).to eq(15)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "has a value" do
|
34
34
|
percentage = described_class.new(19)
|
35
|
-
percentage.value.
|
35
|
+
expect(percentage.value).to eq(19)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "raises exception for value higher than 100" do
|
@@ -50,23 +50,23 @@ end
|
|
50
50
|
|
51
51
|
shared_examples_for 'a DSL feature' do
|
52
52
|
it "returns instance of feature" do
|
53
|
-
feature.
|
53
|
+
expect(feature).to be_instance_of(Flipper::Feature)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "sets name" do
|
57
|
-
feature.name.
|
57
|
+
expect(feature.name).to eq(:stats)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "sets adapter" do
|
61
|
-
feature.adapter.name.
|
61
|
+
expect(feature.adapter.name).to eq(dsl.adapter.name)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "sets instrumenter" do
|
65
|
-
feature.instrumenter.
|
65
|
+
expect(feature.instrumenter).to eq(dsl.instrumenter)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "memoizes the feature" do
|
69
|
-
dsl.send(method_name, :stats).
|
69
|
+
expect(dsl.send(method_name, :stats)).to equal(feature)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "raises argument error if not string or symbol" do
|
@@ -79,11 +79,11 @@ end
|
|
79
79
|
shared_examples_for "a DSL boolean method" do
|
80
80
|
it "returns boolean with value set" do
|
81
81
|
result = subject.send(method_name, true)
|
82
|
-
result.
|
83
|
-
result.value.
|
82
|
+
expect(result).to be_instance_of(Flipper::Types::Boolean)
|
83
|
+
expect(result.value).to be(true)
|
84
84
|
|
85
85
|
result = subject.send(method_name, false)
|
86
|
-
result.
|
87
|
-
result.value.
|
86
|
+
expect(result).to be_instance_of(Flipper::Types::Boolean)
|
87
|
+
expect(result.value).to be(false)
|
88
88
|
end
|
89
89
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'helper'
|
|
2
2
|
require 'flipper/feature'
|
3
3
|
require 'flipper/adapters/memory'
|
4
4
|
|
5
|
-
describe Flipper do
|
5
|
+
RSpec.describe Flipper do
|
6
6
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
7
7
|
let(:flipper) { Flipper.new(adapter) }
|
8
8
|
let(:feature) { flipper[:search] }
|
@@ -33,15 +33,15 @@ describe Flipper do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "returns true" do
|
36
|
-
@result.
|
36
|
+
expect(@result).to eq(true)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "enables feature for all" do
|
40
|
-
feature.enabled
|
40
|
+
expect(feature.enabled?).to eq(true)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "adds feature to set of features" do
|
44
|
-
flipper.features.map(&:name).
|
44
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,31 +51,31 @@ describe Flipper do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "returns true" do
|
54
|
-
@result.
|
54
|
+
expect(@result).to eq(true)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "enables feature for non flipper thing in group" do
|
58
|
-
feature.enabled?(admin_thing).
|
58
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "does not enable feature for non flipper thing in other group" do
|
62
|
-
feature.enabled?(dev_thing).
|
62
|
+
expect(feature.enabled?(dev_thing)).to eq(false)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "enables feature for flipper actor in group" do
|
66
|
-
feature.enabled?(flipper.actor(admin_thing)).
|
66
|
+
expect(feature.enabled?(flipper.actor(admin_thing))).to eq(true)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "does not enable for flipper actor not in group" do
|
70
|
-
feature.enabled?(flipper.actor(dev_thing)).
|
70
|
+
expect(feature.enabled?(flipper.actor(dev_thing))).to eq(false)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "does not enable feature for all" do
|
74
|
-
feature.enabled
|
74
|
+
expect(feature.enabled?).to eq(false)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "adds feature to set of features" do
|
78
|
-
flipper.features.map(&:name).
|
78
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -85,19 +85,19 @@ describe Flipper do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it "returns true" do
|
88
|
-
@result.
|
88
|
+
expect(@result).to eq(true)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "enables feature for actor" do
|
92
|
-
feature.enabled?(pitt).
|
92
|
+
expect(feature.enabled?(pitt)).to eq(true)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "does not enable feature for other actors" do
|
96
|
-
feature.enabled?(clooney).
|
96
|
+
expect(feature.enabled?(clooney)).to eq(false)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "adds feature to set of features" do
|
100
|
-
flipper.features.map(&:name).
|
100
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -107,7 +107,7 @@ describe Flipper do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
it "returns true" do
|
110
|
-
@result.
|
110
|
+
expect(@result).to eq(true)
|
111
111
|
end
|
112
112
|
|
113
113
|
it "enables feature for actor within percentage" do
|
@@ -116,11 +116,11 @@ describe Flipper do
|
|
116
116
|
feature.enabled?(thing)
|
117
117
|
}.size
|
118
118
|
|
119
|
-
enabled.
|
119
|
+
expect(enabled).to be_within(2).of(5)
|
120
120
|
end
|
121
121
|
|
122
122
|
it "adds feature to set of features" do
|
123
|
-
flipper.features.map(&:name).
|
123
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -131,21 +131,21 @@ describe Flipper do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "returns true" do
|
134
|
-
@result.
|
134
|
+
expect(@result).to eq(true)
|
135
135
|
end
|
136
136
|
|
137
137
|
it "enables feature for time within percentage" do
|
138
|
-
@gate.
|
139
|
-
feature.enabled
|
138
|
+
allow(@gate).to receive_messages(:rand => 0.04)
|
139
|
+
expect(feature.enabled?).to eq(true)
|
140
140
|
end
|
141
141
|
|
142
142
|
it "does not enable feature for time not within percentage" do
|
143
|
-
@gate.
|
144
|
-
feature.enabled
|
143
|
+
allow(@gate).to receive_messages(:rand => 0.10)
|
144
|
+
expect(feature.enabled?).to eq(false)
|
145
145
|
end
|
146
146
|
|
147
147
|
it "adds feature to set of features" do
|
148
|
-
flipper.features.map(&:name).
|
148
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -164,7 +164,7 @@ describe Flipper do
|
|
164
164
|
before do
|
165
165
|
# ensures that time gate is stubbed with result that would be true for pitt
|
166
166
|
@gate = feature.gate(:percentage_of_time)
|
167
|
-
@gate.
|
167
|
+
allow(@gate).to receive_messages(:rand => 0.04)
|
168
168
|
|
169
169
|
feature.enable admin_group
|
170
170
|
feature.enable pitt
|
@@ -174,19 +174,19 @@ describe Flipper do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "returns true" do
|
177
|
-
@result.
|
177
|
+
expect(@result).to be(true)
|
178
178
|
end
|
179
179
|
|
180
180
|
it "disables feature" do
|
181
|
-
feature.enabled
|
181
|
+
expect(feature.enabled?).to eq(false)
|
182
182
|
end
|
183
183
|
|
184
184
|
it "disables for individual actor" do
|
185
|
-
feature.enabled?(pitt).
|
185
|
+
expect(feature.enabled?(pitt)).to eq(false)
|
186
186
|
end
|
187
187
|
|
188
188
|
it "disables actor in group" do
|
189
|
-
feature.enabled?(admin_thing).
|
189
|
+
expect(feature.enabled?(admin_thing)).to eq(false)
|
190
190
|
end
|
191
191
|
|
192
192
|
it "disables actor in percentage of actors" do
|
@@ -195,15 +195,15 @@ describe Flipper do
|
|
195
195
|
feature.enabled?(thing)
|
196
196
|
}.size
|
197
197
|
|
198
|
-
enabled.
|
198
|
+
expect(enabled).to be(0)
|
199
199
|
end
|
200
200
|
|
201
201
|
it "disables percentage of time" do
|
202
|
-
feature.enabled?(pitt).
|
202
|
+
expect(feature.enabled?(pitt)).to eq(false)
|
203
203
|
end
|
204
204
|
|
205
205
|
it "adds feature to set of features" do
|
206
|
-
flipper.features.map(&:name).
|
206
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
@@ -215,27 +215,27 @@ describe Flipper do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
it "returns true" do
|
218
|
-
@result.
|
218
|
+
expect(@result).to eq(true)
|
219
219
|
end
|
220
220
|
|
221
221
|
it "disables the feature for non flipper thing in the group" do
|
222
|
-
feature.enabled?(admin_thing).
|
222
|
+
expect(feature.enabled?(admin_thing)).to eq(false)
|
223
223
|
end
|
224
224
|
|
225
225
|
it "does not disable feature for non flipper thing in other groups" do
|
226
|
-
feature.enabled?(dev_thing).
|
226
|
+
expect(feature.enabled?(dev_thing)).to eq(true)
|
227
227
|
end
|
228
228
|
|
229
229
|
it "disables feature for flipper actor in group" do
|
230
|
-
feature.enabled?(flipper.actor(admin_thing)).
|
230
|
+
expect(feature.enabled?(flipper.actor(admin_thing))).to eq(false)
|
231
231
|
end
|
232
232
|
|
233
233
|
it "does not disable feature for flipper actor in other groups" do
|
234
|
-
feature.enabled?(flipper.actor(dev_thing)).
|
234
|
+
expect(feature.enabled?(flipper.actor(dev_thing))).to eq(true)
|
235
235
|
end
|
236
236
|
|
237
237
|
it "adds feature to set of features" do
|
238
|
-
flipper.features.map(&:name).
|
238
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
@@ -247,19 +247,19 @@ describe Flipper do
|
|
247
247
|
end
|
248
248
|
|
249
249
|
it "returns true" do
|
250
|
-
@result.
|
250
|
+
expect(@result).to eq(true)
|
251
251
|
end
|
252
252
|
|
253
253
|
it "disables feature for actor" do
|
254
|
-
feature.enabled?(pitt).
|
254
|
+
expect(feature.enabled?(pitt)).to eq(false)
|
255
255
|
end
|
256
256
|
|
257
257
|
it "does not disable feature for other actors" do
|
258
|
-
feature.enabled?(clooney).
|
258
|
+
expect(feature.enabled?(clooney)).to eq(true)
|
259
259
|
end
|
260
260
|
|
261
261
|
it "adds feature to set of features" do
|
262
|
-
flipper.features.map(&:name).
|
262
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
@@ -269,7 +269,7 @@ describe Flipper do
|
|
269
269
|
end
|
270
270
|
|
271
271
|
it "returns true" do
|
272
|
-
@result.
|
272
|
+
expect(@result).to eq(true)
|
273
273
|
end
|
274
274
|
|
275
275
|
it "disables feature" do
|
@@ -278,11 +278,11 @@ describe Flipper do
|
|
278
278
|
feature.enabled?(thing)
|
279
279
|
}.size
|
280
280
|
|
281
|
-
enabled.
|
281
|
+
expect(enabled).to be(0)
|
282
282
|
end
|
283
283
|
|
284
284
|
it "adds feature to set of features" do
|
285
|
-
flipper.features.map(&:name).
|
285
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
@@ -293,21 +293,21 @@ describe Flipper do
|
|
293
293
|
end
|
294
294
|
|
295
295
|
it "returns true" do
|
296
|
-
@result.
|
296
|
+
expect(@result).to eq(true)
|
297
297
|
end
|
298
298
|
|
299
299
|
it "disables feature for time within percentage" do
|
300
|
-
@gate.
|
301
|
-
feature.enabled
|
300
|
+
allow(@gate).to receive_messages(:rand => 0.04)
|
301
|
+
expect(feature.enabled?).to eq(false)
|
302
302
|
end
|
303
303
|
|
304
304
|
it "disables feature for time not within percentage" do
|
305
|
-
@gate.
|
306
|
-
feature.enabled
|
305
|
+
allow(@gate).to receive_messages(:rand => 0.10)
|
306
|
+
expect(feature.enabled?).to eq(false)
|
307
307
|
end
|
308
308
|
|
309
309
|
it "adds feature to set of features" do
|
310
|
-
flipper.features.map(&:name).
|
310
|
+
expect(flipper.features.map(&:name)).to include(:search)
|
311
311
|
end
|
312
312
|
end
|
313
313
|
|
@@ -324,7 +324,7 @@ describe Flipper do
|
|
324
324
|
describe "#enabled?" do
|
325
325
|
context "with no arguments" do
|
326
326
|
it "defaults to false" do
|
327
|
-
feature.enabled
|
327
|
+
expect(feature.enabled?).to eq(false)
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
@@ -334,7 +334,7 @@ describe Flipper do
|
|
334
334
|
end
|
335
335
|
|
336
336
|
it "returns true" do
|
337
|
-
feature.enabled
|
337
|
+
expect(feature.enabled?).to eq(true)
|
338
338
|
end
|
339
339
|
end
|
340
340
|
|
@@ -344,15 +344,15 @@ describe Flipper do
|
|
344
344
|
end
|
345
345
|
|
346
346
|
it "returns true" do
|
347
|
-
feature.enabled?(flipper.actor(admin_thing)).
|
348
|
-
feature.enabled?(admin_thing).
|
347
|
+
expect(feature.enabled?(flipper.actor(admin_thing))).to eq(true)
|
348
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
352
352
|
context "for actor in disabled group" do
|
353
353
|
it "returns false" do
|
354
|
-
feature.enabled?(flipper.actor(dev_thing)).
|
355
|
-
feature.enabled?(dev_thing).
|
354
|
+
expect(feature.enabled?(flipper.actor(dev_thing))).to eq(false)
|
355
|
+
expect(feature.enabled?(dev_thing)).to eq(false)
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
@@ -362,18 +362,18 @@ describe Flipper do
|
|
362
362
|
end
|
363
363
|
|
364
364
|
it "returns true" do
|
365
|
-
feature.enabled?(pitt).
|
365
|
+
expect(feature.enabled?(pitt)).to eq(true)
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
369
369
|
context "for not enabled actor" do
|
370
370
|
it "returns false" do
|
371
|
-
feature.enabled?(clooney).
|
371
|
+
expect(feature.enabled?(clooney)).to eq(false)
|
372
372
|
end
|
373
373
|
|
374
374
|
it "returns true if boolean enabled" do
|
375
375
|
feature.enable
|
376
|
-
feature.enabled?(clooney).
|
376
|
+
expect(feature.enabled?(clooney)).to eq(true)
|
377
377
|
end
|
378
378
|
end
|
379
379
|
|
@@ -382,16 +382,16 @@ describe Flipper do
|
|
382
382
|
# ensure percentage of time returns percentage that makes five percent
|
383
383
|
# of time true
|
384
384
|
@gate = feature.gate(:percentage_of_time)
|
385
|
-
@gate.
|
385
|
+
allow(@gate).to receive_messages(:rand => 0.04)
|
386
386
|
|
387
387
|
feature.enable five_percent_of_time
|
388
388
|
end
|
389
389
|
|
390
390
|
it "returns true" do
|
391
|
-
feature.enabled
|
392
|
-
feature.enabled?(nil).
|
393
|
-
feature.enabled?(pitt).
|
394
|
-
feature.enabled?(admin_thing).
|
391
|
+
expect(feature.enabled?).to eq(true)
|
392
|
+
expect(feature.enabled?(nil)).to eq(true)
|
393
|
+
expect(feature.enabled?(pitt)).to eq(true)
|
394
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
395
395
|
end
|
396
396
|
end
|
397
397
|
|
@@ -400,24 +400,24 @@ describe Flipper do
|
|
400
400
|
# ensure percentage of time returns percentage that makes five percent
|
401
401
|
# of time false
|
402
402
|
@gate = feature.gate(:percentage_of_time)
|
403
|
-
@gate.
|
403
|
+
allow(@gate).to receive_messages(:rand => 0.10)
|
404
404
|
|
405
405
|
feature.enable five_percent_of_time
|
406
406
|
end
|
407
407
|
|
408
408
|
it "returns false" do
|
409
|
-
feature.enabled
|
410
|
-
feature.enabled?(nil).
|
411
|
-
feature.enabled?(pitt).
|
412
|
-
feature.enabled?(admin_thing).
|
409
|
+
expect(feature.enabled?).to eq(false)
|
410
|
+
expect(feature.enabled?(nil)).to eq(false)
|
411
|
+
expect(feature.enabled?(pitt)).to eq(false)
|
412
|
+
expect(feature.enabled?(admin_thing)).to eq(false)
|
413
413
|
end
|
414
414
|
|
415
415
|
it "returns true if boolean enabled" do
|
416
416
|
feature.enable
|
417
|
-
feature.enabled
|
418
|
-
feature.enabled?(nil).
|
419
|
-
feature.enabled?(pitt).
|
420
|
-
feature.enabled?(admin_thing).
|
417
|
+
expect(feature.enabled?).to eq(true)
|
418
|
+
expect(feature.enabled?(nil)).to eq(true)
|
419
|
+
expect(feature.enabled?(pitt)).to eq(true)
|
420
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
421
421
|
end
|
422
422
|
end
|
423
423
|
|
@@ -427,17 +427,17 @@ describe Flipper do
|
|
427
427
|
end
|
428
428
|
|
429
429
|
it "returns true if in enabled group" do
|
430
|
-
feature.enabled?(admin_thing).
|
430
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
431
431
|
end
|
432
432
|
|
433
433
|
it "returns false if not in enabled group" do
|
434
|
-
feature.enabled?(dev_thing).
|
434
|
+
expect(feature.enabled?(dev_thing)).to eq(false)
|
435
435
|
end
|
436
436
|
|
437
437
|
it "returns true if boolean enabled" do
|
438
438
|
feature.enable
|
439
|
-
feature.enabled?(admin_thing).
|
440
|
-
feature.enabled?(dev_thing).
|
439
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
440
|
+
expect(feature.enabled?(dev_thing)).to eq(true)
|
441
441
|
end
|
442
442
|
end
|
443
443
|
end
|
@@ -451,11 +451,11 @@ describe Flipper do
|
|
451
451
|
end
|
452
452
|
|
453
453
|
it "enables feature for object in enabled group" do
|
454
|
-
feature.enabled?(admin_thing).
|
454
|
+
expect(feature.enabled?(admin_thing)).to eq(true)
|
455
455
|
end
|
456
456
|
|
457
457
|
it "does not enable feature for object in not enabled group" do
|
458
|
-
feature.enabled?(dev_thing).
|
458
|
+
expect(feature.enabled?(dev_thing)).to eq(false)
|
459
459
|
end
|
460
460
|
end
|
461
461
|
end
|