flipper 0.6.1 → 0.6.2
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 +7 -0
- data/Gemfile +1 -1
- data/lib/flipper.rb +8 -1
- data/lib/flipper/feature.rb +1 -1
- data/lib/flipper/instrumentation/statsd_subscriber.rb +1 -1
- data/lib/flipper/registry.rb +7 -1
- data/lib/flipper/spec/shared_adapter_specs.rb +43 -43
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/memoizable_spec.rb +4 -4
- data/spec/flipper/feature_spec.rb +1 -1
- data/spec/flipper/gates/boolean_spec.rb +12 -12
- data/spec/flipper/gates/group_spec.rb +1 -1
- data/spec/flipper/gates/percentage_of_random_spec.rb +1 -1
- data/spec/flipper/instrumenters/noop_spec.rb +2 -2
- data/spec/flipper/middleware/memoizer_spec.rb +3 -3
- data/spec/flipper/registry_spec.rb +14 -0
- data/spec/flipper/types/actor_spec.rb +6 -6
- data/spec/flipper/types/group_spec.rb +2 -2
- data/spec/flipper/types/percentage_spec.rb +4 -4
- data/spec/flipper_spec.rb +11 -0
- data/spec/integration_spec.rb +59 -59
- metadata +10 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 443602b7b9c4e35349dcf1a0f78da58839d7ce63
|
4
|
+
data.tar.gz: beba70f2d2cadf459ac88a90bddb723e3ccefcef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5635c48d957d327148478fb2d5b2e1995d902be5c8f9eb80be4bf6d8465c1a8add294a67c53657716680ae5b597b777af0a998dfaf96d17a3ef62d91bc76e486
|
7
|
+
data.tar.gz: 60d23d5b7a1795828e3fbfd513b593360ab19e4cd6318b4ec6eb6850ab4da9c1dc2c2d4291b5a75e66cdbd458781af1dbc2ba60bf4296f606630e61341d26193
|
data/Gemfile
CHANGED
data/lib/flipper.rb
CHANGED
@@ -16,7 +16,7 @@ module Flipper
|
|
16
16
|
#
|
17
17
|
# Examples
|
18
18
|
#
|
19
|
-
# Flipper.
|
19
|
+
# Flipper.register(:admins) { |thing|
|
20
20
|
# thing.respond_to?(:admin?) && thing.admin?
|
21
21
|
# }
|
22
22
|
#
|
@@ -37,6 +37,13 @@ module Flipper
|
|
37
37
|
groups.clear
|
38
38
|
end
|
39
39
|
|
40
|
+
# Public: Check if a group exists
|
41
|
+
#
|
42
|
+
# Returns boolean
|
43
|
+
def self.group_exists?(name)
|
44
|
+
self.groups.key?(name)
|
45
|
+
end
|
46
|
+
|
40
47
|
# Internal: Fetches a group by name.
|
41
48
|
#
|
42
49
|
# name - The Symbol name of the group.
|
data/lib/flipper/feature.rb
CHANGED
@@ -8,7 +8,7 @@ module Flipper
|
|
8
8
|
# Private: The name of instrumentation events.
|
9
9
|
InstrumentationName = "feature_operation.#{InstrumentationNamespace}"
|
10
10
|
|
11
|
-
#
|
11
|
+
# Public: The name of the feature.
|
12
12
|
attr_reader :name
|
13
13
|
|
14
14
|
# Internal: Name converted to value safe for adapter.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Note: You should never need to require this file directly if you are using
|
2
|
-
# ActiveSupport::Notifications. Instead, you should require the
|
2
|
+
# ActiveSupport::Notifications. Instead, you should require the statsd file
|
3
3
|
# that lives in the same directory as this file. The benefit is that it
|
4
4
|
# subscribes to the correct events and does everything for your.
|
5
5
|
require 'flipper/instrumentation/subscriber'
|
data/lib/flipper/registry.rb
CHANGED
@@ -45,7 +45,6 @@ module Flipper
|
|
45
45
|
|
46
46
|
def get(key)
|
47
47
|
key = key.to_sym
|
48
|
-
|
49
48
|
@mutex.synchronize {
|
50
49
|
@source.fetch(key) {
|
51
50
|
raise KeyNotFound.new(key)
|
@@ -53,6 +52,13 @@ module Flipper
|
|
53
52
|
}
|
54
53
|
end
|
55
54
|
|
55
|
+
def key?(key)
|
56
|
+
key = key.to_sym
|
57
|
+
@mutex.synchronize {
|
58
|
+
@source.has_key?(key)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
56
62
|
def each(&block)
|
57
63
|
@mutex.synchronize { @source.dup }.each(&block)
|
58
64
|
end
|
@@ -46,26 +46,26 @@ shared_examples_for 'a flipper adapter' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "can enable, disable and get value for boolean gate" do
|
49
|
-
subject.enable(feature, boolean_gate, flipper.boolean).should
|
49
|
+
subject.enable(feature, boolean_gate, flipper.boolean).should eq(true)
|
50
50
|
|
51
51
|
result = subject.get(feature)
|
52
52
|
result[:boolean].should eq('true')
|
53
53
|
|
54
|
-
subject.disable(feature, boolean_gate, flipper.boolean(false)).should
|
54
|
+
subject.disable(feature, boolean_gate, flipper.boolean(false)).should eq(true)
|
55
55
|
|
56
56
|
result = subject.get(feature)
|
57
|
-
result[:boolean].should
|
57
|
+
result[:boolean].should eq(nil)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "fully disables all enabled things when boolean gate disabled" do
|
61
61
|
actor_22 = actor_class.new('22')
|
62
|
-
subject.enable(feature, boolean_gate, flipper.boolean).should
|
63
|
-
subject.enable(feature, group_gate, flipper.group(:admins)).should
|
64
|
-
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should
|
65
|
-
subject.enable(feature, actors_gate, flipper.actors(25)).should
|
66
|
-
subject.enable(feature, random_gate, flipper.random(45)).should
|
62
|
+
subject.enable(feature, boolean_gate, flipper.boolean).should eq(true)
|
63
|
+
subject.enable(feature, group_gate, flipper.group(:admins)).should eq(true)
|
64
|
+
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should eq(true)
|
65
|
+
subject.enable(feature, actors_gate, flipper.actors(25)).should eq(true)
|
66
|
+
subject.enable(feature, random_gate, flipper.random(45)).should eq(true)
|
67
67
|
|
68
|
-
subject.disable(feature, boolean_gate, flipper.boolean).should
|
68
|
+
subject.disable(feature, boolean_gate, flipper.boolean).should eq(true)
|
69
69
|
|
70
70
|
subject.get(feature).should eq({
|
71
71
|
:boolean => nil,
|
@@ -77,17 +77,17 @@ shared_examples_for 'a flipper adapter' do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "can enable, disable and get value for group gate" do
|
80
|
-
subject.enable(feature, group_gate, flipper.group(:admins)).should
|
81
|
-
subject.enable(feature, group_gate, flipper.group(:early_access)).should
|
80
|
+
subject.enable(feature, group_gate, flipper.group(:admins)).should eq(true)
|
81
|
+
subject.enable(feature, group_gate, flipper.group(:early_access)).should eq(true)
|
82
82
|
|
83
83
|
result = subject.get(feature)
|
84
84
|
result[:groups].should eq(Set['admins', 'early_access'])
|
85
85
|
|
86
|
-
subject.disable(feature, group_gate, flipper.group(:early_access)).should
|
86
|
+
subject.disable(feature, group_gate, flipper.group(:early_access)).should eq(true)
|
87
87
|
result = subject.get(feature)
|
88
88
|
result[:groups].should eq(Set['admins'])
|
89
89
|
|
90
|
-
subject.disable(feature, group_gate, flipper.group(:admins)).should
|
90
|
+
subject.disable(feature, group_gate, flipper.group(:admins)).should eq(true)
|
91
91
|
result = subject.get(feature)
|
92
92
|
result[:groups].should eq(Set.new)
|
93
93
|
end
|
@@ -96,67 +96,67 @@ shared_examples_for 'a flipper adapter' do
|
|
96
96
|
actor_22 = actor_class.new('22')
|
97
97
|
actor_asdf = actor_class.new('asdf')
|
98
98
|
|
99
|
-
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should
|
100
|
-
subject.enable(feature, actor_gate, flipper.actor(actor_asdf)).should
|
99
|
+
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should eq(true)
|
100
|
+
subject.enable(feature, actor_gate, flipper.actor(actor_asdf)).should eq(true)
|
101
101
|
|
102
102
|
result = subject.get(feature)
|
103
103
|
result[:actors].should eq(Set['22', 'asdf'])
|
104
104
|
|
105
|
-
subject.disable(feature, actor_gate, flipper.actor(actor_22)).should
|
105
|
+
subject.disable(feature, actor_gate, flipper.actor(actor_22)).should eq(true)
|
106
106
|
result = subject.get(feature)
|
107
107
|
result[:actors].should eq(Set['asdf'])
|
108
108
|
|
109
|
-
subject.disable(feature, actor_gate, flipper.actor(actor_asdf)).should
|
109
|
+
subject.disable(feature, actor_gate, flipper.actor(actor_asdf)).should eq(true)
|
110
110
|
result = subject.get(feature)
|
111
111
|
result[:actors].should eq(Set.new)
|
112
112
|
end
|
113
113
|
|
114
114
|
it "can enable, disable and get value for percentage of actors gate" do
|
115
|
-
subject.enable(feature, actors_gate, flipper.actors(15)).should
|
115
|
+
subject.enable(feature, actors_gate, flipper.actors(15)).should eq(true)
|
116
116
|
result = subject.get(feature)
|
117
117
|
result[:percentage_of_actors].should eq('15')
|
118
118
|
|
119
|
-
subject.disable(feature, actors_gate, flipper.actors(0)).should
|
119
|
+
subject.disable(feature, actors_gate, flipper.actors(0)).should eq(true)
|
120
120
|
result = subject.get(feature)
|
121
121
|
result[:percentage_of_actors].should eq('0')
|
122
122
|
end
|
123
123
|
|
124
124
|
it "can enable, disable and get value for percentage of random gate" do
|
125
|
-
subject.enable(feature, random_gate, flipper.random(10)).should
|
125
|
+
subject.enable(feature, random_gate, flipper.random(10)).should eq(true)
|
126
126
|
result = subject.get(feature)
|
127
127
|
result[:percentage_of_random].should eq('10')
|
128
128
|
|
129
|
-
subject.disable(feature, random_gate, flipper.random(0)).should
|
129
|
+
subject.disable(feature, random_gate, flipper.random(0)).should eq(true)
|
130
130
|
result = subject.get(feature)
|
131
131
|
result[:percentage_of_random].should eq('0')
|
132
132
|
end
|
133
133
|
|
134
134
|
it "converts boolean value to a string" do
|
135
|
-
subject.enable(feature, boolean_gate, flipper.boolean).should
|
135
|
+
subject.enable(feature, boolean_gate, flipper.boolean).should eq(true)
|
136
136
|
result = subject.get(feature)
|
137
137
|
result[:boolean].should eq('true')
|
138
138
|
end
|
139
139
|
|
140
140
|
it "converts the actor value to a string" do
|
141
|
-
subject.enable(feature, actor_gate, flipper.actor(actor_class.new(22))).should
|
141
|
+
subject.enable(feature, actor_gate, flipper.actor(actor_class.new(22))).should eq(true)
|
142
142
|
result = subject.get(feature)
|
143
143
|
result[:actors].should eq(Set['22'])
|
144
144
|
end
|
145
145
|
|
146
146
|
it "converts group value to a string" do
|
147
|
-
subject.enable(feature, group_gate, flipper.group(:admins)).should
|
147
|
+
subject.enable(feature, group_gate, flipper.group(:admins)).should eq(true)
|
148
148
|
result = subject.get(feature)
|
149
149
|
result[:groups].should eq(Set['admins'])
|
150
150
|
end
|
151
151
|
|
152
152
|
it "converts percentage of random integer value to a string" do
|
153
|
-
subject.enable(feature, random_gate, flipper.random(10)).should
|
153
|
+
subject.enable(feature, random_gate, flipper.random(10)).should eq(true)
|
154
154
|
result = subject.get(feature)
|
155
155
|
result[:percentage_of_random].should eq('10')
|
156
156
|
end
|
157
157
|
|
158
158
|
it "converts percentage of actors integer value to a string" do
|
159
|
-
subject.enable(feature, actors_gate, flipper.actors(10)).should
|
159
|
+
subject.enable(feature, actors_gate, flipper.actors(10)).should eq(true)
|
160
160
|
result = subject.get(feature)
|
161
161
|
result[:percentage_of_actors].should eq('10')
|
162
162
|
end
|
@@ -164,28 +164,28 @@ shared_examples_for 'a flipper adapter' do
|
|
164
164
|
it "can add, remove and list known features" do
|
165
165
|
subject.features.should eq(Set.new)
|
166
166
|
|
167
|
-
subject.add(flipper[:stats]).should
|
167
|
+
subject.add(flipper[:stats]).should eq(true)
|
168
168
|
subject.features.should eq(Set['stats'])
|
169
169
|
|
170
|
-
subject.add(flipper[:search]).should
|
170
|
+
subject.add(flipper[:search]).should eq(true)
|
171
171
|
subject.features.should eq(Set['stats', 'search'])
|
172
172
|
|
173
|
-
subject.remove(flipper[:stats]).should
|
173
|
+
subject.remove(flipper[:stats]).should eq(true)
|
174
174
|
subject.features.should eq(Set['search'])
|
175
175
|
|
176
|
-
subject.remove(flipper[:search]).should
|
176
|
+
subject.remove(flipper[:search]).should eq(true)
|
177
177
|
subject.features.should eq(Set.new)
|
178
178
|
end
|
179
179
|
|
180
180
|
it "clears all the gate values for the feature on remove" do
|
181
181
|
actor_22 = actor_class.new('22')
|
182
|
-
subject.enable(feature, boolean_gate, flipper.boolean).should
|
183
|
-
subject.enable(feature, group_gate, flipper.group(:admins)).should
|
184
|
-
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should
|
185
|
-
subject.enable(feature, actors_gate, flipper.actors(25)).should
|
186
|
-
subject.enable(feature, random_gate, flipper.random(45)).should
|
182
|
+
subject.enable(feature, boolean_gate, flipper.boolean).should eq(true)
|
183
|
+
subject.enable(feature, group_gate, flipper.group(:admins)).should eq(true)
|
184
|
+
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should eq(true)
|
185
|
+
subject.enable(feature, actors_gate, flipper.actors(25)).should eq(true)
|
186
|
+
subject.enable(feature, random_gate, flipper.random(45)).should eq(true)
|
187
187
|
|
188
|
-
subject.remove(feature).should
|
188
|
+
subject.remove(feature).should eq(true)
|
189
189
|
|
190
190
|
subject.get(feature).should eq({
|
191
191
|
:boolean => nil,
|
@@ -198,13 +198,13 @@ shared_examples_for 'a flipper adapter' do
|
|
198
198
|
|
199
199
|
it "can clear all the gate values for a feature" do
|
200
200
|
actor_22 = actor_class.new('22')
|
201
|
-
subject.enable(feature, boolean_gate, flipper.boolean).should
|
202
|
-
subject.enable(feature, group_gate, flipper.group(:admins)).should
|
203
|
-
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should
|
204
|
-
subject.enable(feature, actors_gate, flipper.actors(25)).should
|
205
|
-
subject.enable(feature, random_gate, flipper.random(45)).should
|
201
|
+
subject.enable(feature, boolean_gate, flipper.boolean).should eq(true)
|
202
|
+
subject.enable(feature, group_gate, flipper.group(:admins)).should eq(true)
|
203
|
+
subject.enable(feature, actor_gate, flipper.actor(actor_22)).should eq(true)
|
204
|
+
subject.enable(feature, actors_gate, flipper.actors(25)).should eq(true)
|
205
|
+
subject.enable(feature, random_gate, flipper.random(45)).should eq(true)
|
206
206
|
|
207
|
-
subject.clear(feature).should
|
207
|
+
subject.clear(feature).any?.should eq(true)
|
208
208
|
|
209
209
|
subject.get(feature).should eq({
|
210
210
|
:boolean => nil,
|
@@ -216,6 +216,6 @@ shared_examples_for 'a flipper adapter' do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it "does not complain clearing a feature that does not exist in adapter" do
|
219
|
-
subject.clear(flipper[:stats]).should
|
219
|
+
subject.clear(flipper[:stats]).any?.should eq(true)
|
220
220
|
end
|
221
221
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -21,10 +21,10 @@ describe Flipper::Adapters::Memoizable do
|
|
21
21
|
describe "#memoize=" do
|
22
22
|
it "sets value" do
|
23
23
|
subject.memoize = true
|
24
|
-
subject.memoizing?.should
|
24
|
+
subject.memoizing?.should eq(true)
|
25
25
|
|
26
26
|
subject.memoize = false
|
27
|
-
subject.memoizing?.should
|
27
|
+
subject.memoizing?.should eq(false)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "clears the local cache" do
|
@@ -37,12 +37,12 @@ describe Flipper::Adapters::Memoizable do
|
|
37
37
|
describe "#memoizing?" do
|
38
38
|
it "returns true if enabled" do
|
39
39
|
subject.memoize = true
|
40
|
-
subject.memoizing?.should
|
40
|
+
subject.memoizing?.should eq(true)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "returns false if disabled" do
|
44
44
|
subject.memoize = false
|
45
|
-
subject.memoizing?.should
|
45
|
+
subject.memoizing?.should eq(false)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -142,7 +142,7 @@ describe Flipper::Feature do
|
|
142
142
|
event.payload[:feature_name].should eq(:search)
|
143
143
|
event.payload[:operation].should eq(:enabled?)
|
144
144
|
event.payload[:thing].should eq(thing)
|
145
|
-
event.payload[:result].should
|
145
|
+
event.payload[:result].should eq(false)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -26,37 +26,37 @@ describe Flipper::Gates::Boolean do
|
|
26
26
|
describe "#enabled?" do
|
27
27
|
context "for true value" do
|
28
28
|
it "returns true" do
|
29
|
-
subject.enabled?(true).should
|
29
|
+
subject.enabled?(true).should eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "for false value" do
|
34
34
|
it "returns false" do
|
35
|
-
subject.enabled?(false).should
|
35
|
+
subject.enabled?(false).should eq(false)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
context "for nil value" do
|
40
40
|
it "returns false" do
|
41
|
-
subject.enabled?(nil).should
|
41
|
+
subject.enabled?(nil).should eq(false)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
context "for empty string value" do
|
46
46
|
it "returns false" do
|
47
|
-
subject.enabled?('').should
|
47
|
+
subject.enabled?('').should eq(false)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
context "for the string true value" do
|
52
52
|
it "returns true" do
|
53
|
-
subject.enabled?('true').should
|
53
|
+
subject.enabled?('true').should eq(true)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
context "for the string false value" do
|
58
58
|
it "returns false" do
|
59
|
-
subject.enabled?('false').should
|
59
|
+
subject.enabled?('false').should eq(false)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -64,37 +64,37 @@ describe Flipper::Gates::Boolean do
|
|
64
64
|
describe "#open?" do
|
65
65
|
context "for true value" do
|
66
66
|
it "returns true" do
|
67
|
-
subject.open?(Object.new, true).should
|
67
|
+
subject.open?(Object.new, true).should eq(true)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
context "for false value" do
|
72
72
|
it "returns false" do
|
73
|
-
subject.open?(Object.new, false).should
|
73
|
+
subject.open?(Object.new, false).should eq(false)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
context "for nil value" do
|
78
78
|
it "returns false" do
|
79
|
-
subject.open?(Object.new, nil).should
|
79
|
+
subject.open?(Object.new, nil).should eq(false)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
context "for string true value" do
|
84
84
|
it "returns true" do
|
85
|
-
subject.open?(Object.new, 'true').should
|
85
|
+
subject.open?(Object.new, 'true').should eq(true)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
context "for string false value" do
|
90
90
|
it "returns false" do
|
91
|
-
subject.open?(Object.new, 'false').should
|
91
|
+
subject.open?(Object.new, 'false').should eq(false)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
context "for an empty string value" do
|
96
96
|
it "returns false" do
|
97
|
-
subject.open?(Object.new, '').should
|
97
|
+
subject.open?(Object.new, '').should eq(false)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -24,7 +24,7 @@ describe Flipper::Gates::PercentageOfRandom do
|
|
24
24
|
event.payload[:feature_name].should eq(:search)
|
25
25
|
|
26
26
|
# random so don't test value
|
27
|
-
event.payload.key?(:result).should
|
27
|
+
event.payload.key?(:result).should eq(true)
|
28
28
|
event.payload[:result].should_not be_nil
|
29
29
|
end
|
30
30
|
end
|
@@ -7,7 +7,7 @@ describe Flipper::Instrumenters::Noop do
|
|
7
7
|
it "yields block" do
|
8
8
|
yielded = false
|
9
9
|
described_class.instrument(:foo) { yielded = true }
|
10
|
-
yielded.should
|
10
|
+
yielded.should eq(true)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ describe Flipper::Instrumenters::Noop do
|
|
15
15
|
it "yields block" do
|
16
16
|
yielded = false
|
17
17
|
described_class.instrument(:foo, {:pay => :load}) { yielded = true }
|
18
|
-
yielded.should
|
18
|
+
yielded.should eq(true)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -27,7 +27,7 @@ describe Flipper::Middleware::Memoizer do
|
|
27
27
|
}
|
28
28
|
middleware = described_class.new app, flipper
|
29
29
|
middleware.call({})
|
30
|
-
called.should
|
30
|
+
called.should eq(true)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "disables local cache after body close" do
|
@@ -35,9 +35,9 @@ describe Flipper::Middleware::Memoizer do
|
|
35
35
|
middleware = described_class.new app, flipper
|
36
36
|
body = middleware.call({}).last
|
37
37
|
|
38
|
-
flipper.adapter.memoizing?.should
|
38
|
+
flipper.adapter.memoizing?.should eq(true)
|
39
39
|
body.close
|
40
|
-
flipper.adapter.memoizing?.should
|
40
|
+
flipper.adapter.memoizing?.should eq(false)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "clears local cache after body close" do
|
@@ -52,6 +52,20 @@ describe Flipper::Registry do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
describe "#key?" do
|
56
|
+
before do
|
57
|
+
source[:admins] = "admins"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns true if the key exists" do
|
61
|
+
subject.key?(:admins).should eq true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns false if the key does not exists" do
|
65
|
+
subject.key?(:unknown_key).should eq false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
55
69
|
describe "#each" do
|
56
70
|
before do
|
57
71
|
source[:admins] = 'admins'
|
@@ -25,12 +25,12 @@ describe Flipper::Types::Actor do
|
|
25
25
|
it "returns true if actor" do
|
26
26
|
thing = thing_class.new('1')
|
27
27
|
actor = described_class.new(thing)
|
28
|
-
described_class.wrappable?(actor).should
|
28
|
+
described_class.wrappable?(actor).should eq(true)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns true if responds to id" do
|
32
32
|
thing = thing_class.new(10)
|
33
|
-
described_class.wrappable?(thing).should
|
33
|
+
described_class.wrappable?(thing).should eq(true)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -80,26 +80,26 @@ describe Flipper::Types::Actor do
|
|
80
80
|
it "proxies everything to thing" do
|
81
81
|
thing = thing_class.new(10)
|
82
82
|
actor = described_class.new(thing)
|
83
|
-
actor.admin?.should
|
83
|
+
actor.admin?.should eq(true)
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "#respond_to?" do
|
87
87
|
it "returns true if responds to method" do
|
88
88
|
thing = thing_class.new('1')
|
89
89
|
actor = described_class.new(thing)
|
90
|
-
actor.respond_to?(:value).should
|
90
|
+
actor.respond_to?(:value).should eq(true)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "returns true if thing responds to method" do
|
94
94
|
thing = thing_class.new(10)
|
95
95
|
actor = described_class.new(thing)
|
96
|
-
actor.respond_to?(:admin?).should
|
96
|
+
actor.respond_to?(:admin?).should eq(true)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "returns false if does not respond to method and thing does not respond to method" do
|
100
100
|
thing = thing_class.new(10)
|
101
101
|
actor = described_class.new(thing)
|
102
|
-
actor.respond_to?(:frankenstein).should
|
102
|
+
actor.respond_to?(:frankenstein).should eq(false)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -22,11 +22,11 @@ describe Flipper::Types::Group do
|
|
22
22
|
let(:non_admin_actor) { double('Actor', :admin? => false) }
|
23
23
|
|
24
24
|
it "returns true if block matches" do
|
25
|
-
subject.match?(admin_actor).should
|
25
|
+
subject.match?(admin_actor).should eq(true)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns false if block does not match" do
|
29
|
-
subject.match?(non_admin_actor).should
|
29
|
+
subject.match?(non_admin_actor).should eq(false)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -9,19 +9,19 @@ describe Flipper::Types::Percentage do
|
|
9
9
|
|
10
10
|
describe "#eql?" do
|
11
11
|
it "returns true for same class and value" do
|
12
|
-
subject.eql?(described_class.new(subject.value)).should
|
12
|
+
subject.eql?(described_class.new(subject.value)).should eq(true)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns false for different value" do
|
16
|
-
subject.eql?(described_class.new(subject.value + 1)).should
|
16
|
+
subject.eql?(described_class.new(subject.value + 1)).should eq(false)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns false for different class" do
|
20
|
-
subject.eql?(Object.new).should
|
20
|
+
subject.eql?(Object.new).should eq(false)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "is aliased to ==" do
|
24
|
-
(subject == described_class.new(subject.value)).should
|
24
|
+
(subject == described_class.new(subject.value)).should eq(true)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/spec/flipper_spec.rb
CHANGED
@@ -8,6 +8,17 @@ describe Flipper do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
describe ".group_exists" do
|
12
|
+
it "returns true if the group is already created" do
|
13
|
+
group = Flipper.register('admins') { |actor| actor.admin? }
|
14
|
+
Flipper.group_exists?(:admins).should eq(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns false when the group is not yet registered" do
|
18
|
+
Flipper.group_exists?(:non_existing).should eq(false)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
11
22
|
describe ".groups" do
|
12
23
|
it "returns a registry instance" do
|
13
24
|
Flipper.groups.should be_instance_of(Flipper::Registry)
|
data/spec/integration_spec.rb
CHANGED
@@ -35,11 +35,11 @@ describe Flipper do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "returns true" do
|
38
|
-
@result.should
|
38
|
+
@result.should eq(true)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "enables feature for all" do
|
42
|
-
feature.enabled?.should
|
42
|
+
feature.enabled?.should eq(true)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "adds feature to set of features" do
|
@@ -53,27 +53,27 @@ describe Flipper do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "returns true" do
|
56
|
-
@result.should
|
56
|
+
@result.should eq(true)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "enables feature for non flipper thing in group" do
|
60
|
-
feature.enabled?(admin_thing).should
|
60
|
+
feature.enabled?(admin_thing).should eq(true)
|
61
61
|
end
|
62
62
|
|
63
63
|
it "does not enable feature for non flipper thing in other group" do
|
64
|
-
feature.enabled?(dev_thing).should
|
64
|
+
feature.enabled?(dev_thing).should eq(false)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "enables feature for flipper actor in group" do
|
68
|
-
feature.enabled?(flipper.actor(admin_thing)).should
|
68
|
+
feature.enabled?(flipper.actor(admin_thing)).should eq(true)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "does not enable for flipper actor not in group" do
|
72
|
-
feature.enabled?(flipper.actor(dev_thing)).should
|
72
|
+
feature.enabled?(flipper.actor(dev_thing)).should eq(false)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "does not enable feature for all" do
|
76
|
-
feature.enabled?.should
|
76
|
+
feature.enabled?.should eq(false)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "adds feature to set of features" do
|
@@ -87,15 +87,15 @@ describe Flipper do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "returns true" do
|
90
|
-
@result.should
|
90
|
+
@result.should eq(true)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "enables feature for actor" do
|
94
|
-
feature.enabled?(pitt).should
|
94
|
+
feature.enabled?(pitt).should eq(true)
|
95
95
|
end
|
96
96
|
|
97
97
|
it "does not enable feature for other actors" do
|
98
|
-
feature.enabled?(clooney).should
|
98
|
+
feature.enabled?(clooney).should eq(false)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "adds feature to set of features" do
|
@@ -109,7 +109,7 @@ describe Flipper do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "returns true" do
|
112
|
-
@result.should
|
112
|
+
@result.should eq(true)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "enables feature for actor within percentage" do
|
@@ -133,17 +133,17 @@ describe Flipper do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it "returns true" do
|
136
|
-
@result.should
|
136
|
+
@result.should eq(true)
|
137
137
|
end
|
138
138
|
|
139
139
|
it "enables feature for time within percentage" do
|
140
140
|
@gate.stub(:rand => 0.04)
|
141
|
-
feature.enabled?.should
|
141
|
+
feature.enabled?.should eq(true)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "does not enable feature for time not within percentage" do
|
145
145
|
@gate.stub(:rand => 0.10)
|
146
|
-
feature.enabled?.should
|
146
|
+
feature.enabled?.should eq(false)
|
147
147
|
end
|
148
148
|
|
149
149
|
it "adds feature to set of features" do
|
@@ -176,19 +176,19 @@ describe Flipper do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
it "returns true" do
|
179
|
-
@result.should
|
179
|
+
@result.should be_truthy
|
180
180
|
end
|
181
181
|
|
182
182
|
it "disables feature" do
|
183
|
-
feature.enabled?.should
|
183
|
+
feature.enabled?.should eq(false)
|
184
184
|
end
|
185
185
|
|
186
186
|
it "disables for individual actor" do
|
187
|
-
feature.enabled?(pitt).should
|
187
|
+
feature.enabled?(pitt).should eq(false)
|
188
188
|
end
|
189
189
|
|
190
190
|
it "disables actor in group" do
|
191
|
-
feature.enabled?(admin_thing).should
|
191
|
+
feature.enabled?(admin_thing).should eq(false)
|
192
192
|
end
|
193
193
|
|
194
194
|
it "disables actor in percentage of actors" do
|
@@ -201,7 +201,7 @@ describe Flipper do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it "disables percentage of random" do
|
204
|
-
feature.enabled?(pitt).should
|
204
|
+
feature.enabled?(pitt).should eq(false)
|
205
205
|
end
|
206
206
|
|
207
207
|
it "adds feature to set of features" do
|
@@ -217,23 +217,23 @@ describe Flipper do
|
|
217
217
|
end
|
218
218
|
|
219
219
|
it "returns true" do
|
220
|
-
@result.should
|
220
|
+
@result.should eq(true)
|
221
221
|
end
|
222
222
|
|
223
223
|
it "disables the feature for non flipper thing in the group" do
|
224
|
-
feature.enabled?(admin_thing).should
|
224
|
+
feature.enabled?(admin_thing).should eq(false)
|
225
225
|
end
|
226
226
|
|
227
227
|
it "does not disable feature for non flipper thing in other groups" do
|
228
|
-
feature.enabled?(dev_thing).should
|
228
|
+
feature.enabled?(dev_thing).should eq(true)
|
229
229
|
end
|
230
230
|
|
231
231
|
it "disables feature for flipper actor in group" do
|
232
|
-
feature.enabled?(flipper.actor(admin_thing)).should
|
232
|
+
feature.enabled?(flipper.actor(admin_thing)).should eq(false)
|
233
233
|
end
|
234
234
|
|
235
235
|
it "does not disable feature for flipper actor in other groups" do
|
236
|
-
feature.enabled?(flipper.actor(dev_thing)).should
|
236
|
+
feature.enabled?(flipper.actor(dev_thing)).should eq(true)
|
237
237
|
end
|
238
238
|
|
239
239
|
it "adds feature to set of features" do
|
@@ -249,15 +249,15 @@ describe Flipper do
|
|
249
249
|
end
|
250
250
|
|
251
251
|
it "returns true" do
|
252
|
-
@result.should
|
252
|
+
@result.should eq(true)
|
253
253
|
end
|
254
254
|
|
255
255
|
it "disables feature for actor" do
|
256
|
-
feature.enabled?(pitt).should
|
256
|
+
feature.enabled?(pitt).should eq(false)
|
257
257
|
end
|
258
258
|
|
259
259
|
it "does not disable feature for other actors" do
|
260
|
-
feature.enabled?(clooney).should
|
260
|
+
feature.enabled?(clooney).should eq(true)
|
261
261
|
end
|
262
262
|
|
263
263
|
it "adds feature to set of features" do
|
@@ -271,7 +271,7 @@ describe Flipper do
|
|
271
271
|
end
|
272
272
|
|
273
273
|
it "returns true" do
|
274
|
-
@result.should
|
274
|
+
@result.should eq(true)
|
275
275
|
end
|
276
276
|
|
277
277
|
it "disables feature" do
|
@@ -295,17 +295,17 @@ describe Flipper do
|
|
295
295
|
end
|
296
296
|
|
297
297
|
it "returns true" do
|
298
|
-
@result.should
|
298
|
+
@result.should eq(true)
|
299
299
|
end
|
300
300
|
|
301
301
|
it "disables feature for time within percentage" do
|
302
302
|
@gate.stub(:rand => 0.04)
|
303
|
-
feature.enabled?.should
|
303
|
+
feature.enabled?.should eq(false)
|
304
304
|
end
|
305
305
|
|
306
306
|
it "disables feature for time not within percentage" do
|
307
307
|
@gate.stub(:rand => 0.10)
|
308
|
-
feature.enabled?.should
|
308
|
+
feature.enabled?.should eq(false)
|
309
309
|
end
|
310
310
|
|
311
311
|
it "adds feature to set of features" do
|
@@ -326,7 +326,7 @@ describe Flipper do
|
|
326
326
|
describe "#enabled?" do
|
327
327
|
context "with no arguments" do
|
328
328
|
it "defaults to false" do
|
329
|
-
feature.enabled?.should
|
329
|
+
feature.enabled?.should eq(false)
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
@@ -336,7 +336,7 @@ describe Flipper do
|
|
336
336
|
end
|
337
337
|
|
338
338
|
it "returns true" do
|
339
|
-
feature.enabled?.should
|
339
|
+
feature.enabled?.should eq(true)
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
@@ -346,15 +346,15 @@ describe Flipper do
|
|
346
346
|
end
|
347
347
|
|
348
348
|
it "returns true" do
|
349
|
-
feature.enabled?(flipper.actor(admin_thing)).should
|
350
|
-
feature.enabled?(admin_thing).should
|
349
|
+
feature.enabled?(flipper.actor(admin_thing)).should eq(true)
|
350
|
+
feature.enabled?(admin_thing).should eq(true)
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
354
354
|
context "for actor in disabled group" do
|
355
355
|
it "returns false" do
|
356
|
-
feature.enabled?(flipper.actor(dev_thing)).should
|
357
|
-
feature.enabled?(dev_thing).should
|
356
|
+
feature.enabled?(flipper.actor(dev_thing)).should eq(false)
|
357
|
+
feature.enabled?(dev_thing).should eq(false)
|
358
358
|
end
|
359
359
|
end
|
360
360
|
|
@@ -364,18 +364,18 @@ describe Flipper do
|
|
364
364
|
end
|
365
365
|
|
366
366
|
it "returns true" do
|
367
|
-
feature.enabled?(pitt).should
|
367
|
+
feature.enabled?(pitt).should eq(true)
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
371
371
|
context "for not enabled actor" do
|
372
372
|
it "returns false" do
|
373
|
-
feature.enabled?(clooney).should
|
373
|
+
feature.enabled?(clooney).should eq(false)
|
374
374
|
end
|
375
375
|
|
376
376
|
it "returns true if boolean enabled" do
|
377
377
|
feature.enable
|
378
|
-
feature.enabled?(clooney).should
|
378
|
+
feature.enabled?(clooney).should eq(true)
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
@@ -389,10 +389,10 @@ describe Flipper do
|
|
389
389
|
end
|
390
390
|
|
391
391
|
it "returns true" do
|
392
|
-
feature.enabled?.should
|
393
|
-
feature.enabled?(nil).should
|
394
|
-
feature.enabled?(pitt).should
|
395
|
-
feature.enabled?(admin_thing).should
|
392
|
+
feature.enabled?.should eq(true)
|
393
|
+
feature.enabled?(nil).should eq(true)
|
394
|
+
feature.enabled?(pitt).should eq(true)
|
395
|
+
feature.enabled?(admin_thing).should eq(true)
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
@@ -406,18 +406,18 @@ describe Flipper do
|
|
406
406
|
end
|
407
407
|
|
408
408
|
it "returns false" do
|
409
|
-
feature.enabled?.should
|
410
|
-
feature.enabled?(nil).should
|
411
|
-
feature.enabled?(pitt).should
|
412
|
-
feature.enabled?(admin_thing).should
|
409
|
+
feature.enabled?.should eq(false)
|
410
|
+
feature.enabled?(nil).should eq(false)
|
411
|
+
feature.enabled?(pitt).should eq(false)
|
412
|
+
feature.enabled?(admin_thing).should eq(false)
|
413
413
|
end
|
414
414
|
|
415
415
|
it "returns true if boolean enabled" do
|
416
416
|
feature.enable
|
417
|
-
feature.enabled?.should
|
418
|
-
feature.enabled?(nil).should
|
419
|
-
feature.enabled?(pitt).should
|
420
|
-
feature.enabled?(admin_thing).should
|
417
|
+
feature.enabled?.should eq(true)
|
418
|
+
feature.enabled?(nil).should eq(true)
|
419
|
+
feature.enabled?(pitt).should eq(true)
|
420
|
+
feature.enabled?(admin_thing).should 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).should
|
430
|
+
feature.enabled?(admin_thing).should eq(true)
|
431
431
|
end
|
432
432
|
|
433
433
|
it "returns false if not in enabled group" do
|
434
|
-
feature.enabled?(dev_thing).should
|
434
|
+
feature.enabled?(dev_thing).should 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).should
|
440
|
-
feature.enabled?(dev_thing).should
|
439
|
+
feature.enabled?(admin_thing).should eq(true)
|
440
|
+
feature.enabled?(dev_thing).should 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).should
|
454
|
+
feature.enabled?(admin_thing).should 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).should
|
458
|
+
feature.enabled?(dev_thing).should eq(false)
|
459
459
|
end
|
460
460
|
end
|
461
461
|
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Nunemaker
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Feature flipper for any adapter
|
15
14
|
email:
|
@@ -18,9 +17,9 @@ executables: []
|
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- .rspec
|
23
|
-
- .travis.yml
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".travis.yml"
|
24
23
|
- Changelog.md
|
25
24
|
- Gemfile
|
26
25
|
- Guardfile
|
@@ -103,33 +102,26 @@ files:
|
|
103
102
|
- spec/support/fake_udp_socket.rb
|
104
103
|
homepage: http://jnunemaker.github.com/flipper
|
105
104
|
licenses: []
|
105
|
+
metadata: {}
|
106
106
|
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|
110
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
111
|
requirements:
|
113
|
-
- -
|
112
|
+
- - ">="
|
114
113
|
- !ruby/object:Gem::Version
|
115
114
|
version: '0'
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
hash: -2625440176401499604
|
119
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
116
|
requirements:
|
122
|
-
- -
|
117
|
+
- - ">="
|
123
118
|
- !ruby/object:Gem::Version
|
124
119
|
version: '0'
|
125
|
-
segments:
|
126
|
-
- 0
|
127
|
-
hash: -2625440176401499604
|
128
120
|
requirements: []
|
129
121
|
rubyforge_project:
|
130
|
-
rubygems_version:
|
122
|
+
rubygems_version: 2.2.2
|
131
123
|
signing_key:
|
132
|
-
specification_version:
|
124
|
+
specification_version: 4
|
133
125
|
summary: Feature flipper for any adapter
|
134
126
|
test_files:
|
135
127
|
- spec/flipper/adapters/instrumented_spec.rb
|