flipper 0.7.1 → 0.7.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 +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/gate_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
describe Flipper::Gate do
|
3
|
+
RSpec.describe Flipper::Gate do
|
4
4
|
let(:feature_name) { :stats }
|
5
5
|
|
6
6
|
subject {
|
@@ -31,10 +31,10 @@ describe Flipper::Gate do
|
|
31
31
|
|
32
32
|
it "includes attributes" do
|
33
33
|
string = subject.inspect
|
34
|
-
string.
|
35
|
-
string.
|
36
|
-
string.
|
37
|
-
string.
|
34
|
+
expect(string).to include(subject.object_id.to_s)
|
35
|
+
expect(string).to include('name=:name')
|
36
|
+
expect(string).to include('key=:key')
|
37
|
+
expect(string).to include('data_type=:set')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'flipper/gate_values'
|
3
3
|
|
4
|
-
describe Flipper::GateValues do
|
4
|
+
RSpec.describe Flipper::GateValues do
|
5
5
|
{
|
6
6
|
nil => false,
|
7
7
|
"" => false,
|
@@ -16,7 +16,7 @@ describe Flipper::GateValues do
|
|
16
16
|
}.each do |value, expected|
|
17
17
|
context "with #{value.inspect} boolean" do
|
18
18
|
it "returns #{expected}" do
|
19
|
-
described_class.new(boolean: value).boolean.
|
19
|
+
expect(described_class.new(boolean: value).boolean).to be(expected)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -31,7 +31,7 @@ describe Flipper::GateValues do
|
|
31
31
|
}.each do |value, expected|
|
32
32
|
context "with #{value.inspect} percentage of time" do
|
33
33
|
it "returns #{expected}" do
|
34
|
-
described_class.new(percentage_of_time: value).percentage_of_time.
|
34
|
+
expect(described_class.new(percentage_of_time: value).percentage_of_time).to be(expected)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -46,7 +46,7 @@ describe Flipper::GateValues do
|
|
46
46
|
}.each do |value, expected|
|
47
47
|
context "with #{value.inspect} percentage of actors" do
|
48
48
|
it "returns #{expected}" do
|
49
|
-
described_class.new(percentage_of_actors: value).percentage_of_actors.
|
49
|
+
expect(described_class.new(percentage_of_actors: value).percentage_of_actors).to be(expected)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -59,7 +59,7 @@ describe Flipper::GateValues do
|
|
59
59
|
}.each do |value, expected|
|
60
60
|
context "with #{value.inspect} actors" do
|
61
61
|
it "returns #{expected}" do
|
62
|
-
described_class.new(actors: value).actors.
|
62
|
+
expect(described_class.new(actors: value).actors).to eq(expected)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -72,7 +72,7 @@ describe Flipper::GateValues do
|
|
72
72
|
}.each do |value, expected|
|
73
73
|
context "with #{value.inspect} groups" do
|
74
74
|
it "returns #{expected}" do
|
75
|
-
described_class.new(groups: value).groups.
|
75
|
+
expect(described_class.new(groups: value).groups).to eq(expected)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -103,32 +103,32 @@ describe Flipper::GateValues do
|
|
103
103
|
|
104
104
|
describe "#[]" do
|
105
105
|
it "can read the boolean value" do
|
106
|
-
described_class.new(boolean: true)[:boolean].
|
107
|
-
described_class.new(boolean: true)["boolean"].
|
106
|
+
expect(described_class.new(boolean: true)[:boolean]).to be(true)
|
107
|
+
expect(described_class.new(boolean: true)["boolean"]).to be(true)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "can read the actors value" do
|
111
|
-
described_class.new(actors: Set[1, 2])[:actors].
|
112
|
-
described_class.new(actors: Set[1, 2])["actors"].
|
111
|
+
expect(described_class.new(actors: Set[1, 2])[:actors]).to eq(Set[1, 2])
|
112
|
+
expect(described_class.new(actors: Set[1, 2])["actors"]).to eq(Set[1, 2])
|
113
113
|
end
|
114
114
|
|
115
115
|
it "can read the groups value" do
|
116
|
-
described_class.new(groups: Set[:admins])[:groups].
|
117
|
-
described_class.new(groups: Set[:admins])["groups"].
|
116
|
+
expect(described_class.new(groups: Set[:admins])[:groups]).to eq(Set[:admins])
|
117
|
+
expect(described_class.new(groups: Set[:admins])["groups"]).to eq(Set[:admins])
|
118
118
|
end
|
119
119
|
|
120
120
|
it "can read the percentage of time value" do
|
121
|
-
described_class.new(percentage_of_time: 15)[:percentage_of_time].
|
122
|
-
described_class.new(percentage_of_time: 15)["percentage_of_time"].
|
121
|
+
expect(described_class.new(percentage_of_time: 15)[:percentage_of_time]).to eq(15)
|
122
|
+
expect(described_class.new(percentage_of_time: 15)["percentage_of_time"]).to eq(15)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "can read the percentage of actors value" do
|
126
|
-
described_class.new(percentage_of_actors: 15)[:percentage_of_actors].
|
127
|
-
described_class.new(percentage_of_actors: 15)["percentage_of_actors"].
|
126
|
+
expect(described_class.new(percentage_of_actors: 15)[:percentage_of_actors]).to eq(15)
|
127
|
+
expect(described_class.new(percentage_of_actors: 15)["percentage_of_actors"]).to eq(15)
|
128
128
|
end
|
129
129
|
|
130
130
|
it "returns nil for value that is not present" do
|
131
|
-
described_class.new({})["not legit"].
|
131
|
+
expect(described_class.new({})["not legit"]).to be(nil)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
describe Flipper::Gates::Boolean do
|
3
|
+
RSpec.describe Flipper::Gates::Boolean do
|
4
4
|
let(:feature_name) { :search }
|
5
5
|
|
6
6
|
subject {
|
@@ -10,13 +10,13 @@ describe Flipper::Gates::Boolean do
|
|
10
10
|
describe "#enabled?" do
|
11
11
|
context "for true value" do
|
12
12
|
it "returns true" do
|
13
|
-
subject.enabled?(true).
|
13
|
+
expect(subject.enabled?(true)).to eq(true)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
context "for false value" do
|
18
18
|
it "returns false" do
|
19
|
-
subject.enabled?(false).
|
19
|
+
expect(subject.enabled?(false)).to eq(false)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -24,44 +24,44 @@ describe Flipper::Gates::Boolean do
|
|
24
24
|
describe "#open?" do
|
25
25
|
context "for true value" do
|
26
26
|
it "returns true" do
|
27
|
-
subject.open?(Object.new, true, feature_name: feature_name).
|
27
|
+
expect(subject.open?(Object.new, true, feature_name: feature_name)).to eq(true)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
context "for false value" do
|
32
32
|
it "returns false" do
|
33
|
-
subject.open?(Object.new, false, feature_name: feature_name).
|
33
|
+
expect(subject.open?(Object.new, false, feature_name: feature_name)).to eq(false)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#protects?" do
|
39
39
|
it "returns true for boolean type" do
|
40
|
-
subject.protects?(Flipper::Types::Boolean.new(true)).
|
40
|
+
expect(subject.protects?(Flipper::Types::Boolean.new(true))).to be(true)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "returns true for true" do
|
44
|
-
subject.protects?(true).
|
44
|
+
expect(subject.protects?(true)).to be(true)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "returns true for false" do
|
48
|
-
subject.protects?(false).
|
48
|
+
expect(subject.protects?(false)).to be(true)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "#wrap" do
|
53
53
|
it "returns boolean type for boolean type" do
|
54
|
-
subject.wrap(Flipper::Types::Boolean.new(true)).
|
54
|
+
expect(subject.wrap(Flipper::Types::Boolean.new(true))).to be_instance_of(Flipper::Types::Boolean)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "returns boolean type for true" do
|
58
|
-
subject.wrap(true).
|
59
|
-
subject.wrap(true).value.
|
58
|
+
expect(subject.wrap(true)).to be_instance_of(Flipper::Types::Boolean)
|
59
|
+
expect(subject.wrap(true).value).to be(true)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "returns boolean type for true" do
|
63
|
-
subject.wrap(false).
|
64
|
-
subject.wrap(false).value.
|
63
|
+
expect(subject.wrap(false)).to be_instance_of(Flipper::Types::Boolean)
|
64
|
+
expect(subject.wrap(false).value).to be(false)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
describe Flipper::Gates::Group do
|
3
|
+
RSpec.describe Flipper::Gates::Group do
|
4
4
|
let(:feature_name) { :search }
|
5
5
|
|
6
6
|
subject {
|
@@ -15,7 +15,7 @@ describe Flipper::Gates::Group do
|
|
15
15
|
|
16
16
|
it "ignores group" do
|
17
17
|
thing = Struct.new(:flipper_id).new('5')
|
18
|
-
subject.open?(thing, Set[:newbs, :staff], feature_name: feature_name).
|
18
|
+
expect(subject.open?(thing, Set[:newbs, :staff], feature_name: feature_name)).to eq(true)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -35,23 +35,23 @@ describe Flipper::Gates::Group do
|
|
35
35
|
describe "#wrap" do
|
36
36
|
it "returns group instance for symbol" do
|
37
37
|
group = Flipper.register(:admins) {}
|
38
|
-
subject.wrap(:admins).
|
38
|
+
expect(subject.wrap(:admins)).to eq(group)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns group instance for group instance" do
|
42
42
|
group = Flipper.register(:admins) {}
|
43
|
-
subject.wrap(group).
|
43
|
+
expect(subject.wrap(group)).to eq(group)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "#protects?" do
|
48
48
|
it "returns true for group" do
|
49
49
|
group = Flipper.register(:admins) {}
|
50
|
-
subject.protects?(group).
|
50
|
+
expect(subject.protects?(group)).to be(true)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "returns true for symbol" do
|
54
|
-
subject.protects?(:admins).
|
54
|
+
expect(subject.protects?(:admins)).to be(true)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
describe Flipper::Gates::PercentageOfActors do
|
3
|
+
RSpec.describe Flipper::Gates::PercentageOfActors do
|
4
4
|
let(:feature_name) { :search }
|
5
5
|
|
6
6
|
subject {
|
@@ -28,7 +28,7 @@ describe Flipper::Gates::PercentageOfActors do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "does not enable both features for same set of actors" do
|
31
|
-
feature_one_enabled_actors.
|
31
|
+
expect(feature_one_enabled_actors).not_to eq(feature_two_enabled_actors)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "enables feature for accurate number of actors for each feature" do
|
@@ -39,7 +39,7 @@ describe Flipper::Gates::PercentageOfActors do
|
|
39
39
|
feature_one_enabled_actors.size,
|
40
40
|
feature_two_enabled_actors.size,
|
41
41
|
].each do |actual_enabled_size|
|
42
|
-
actual_enabled_size.
|
42
|
+
expect(actual_enabled_size).to be_within(margin_of_error).of(expected_enabled_size)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
require 'flipper/adapters/memory'
|
4
4
|
require 'flipper/instrumentation/log_subscriber'
|
5
5
|
|
6
|
-
describe Flipper::Instrumentation::LogSubscriber do
|
6
|
+
RSpec.describe Flipper::Instrumentation::LogSubscriber do
|
7
7
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
8
8
|
let(:flipper) {
|
9
9
|
Flipper.new(adapter, :instrumenter => ActiveSupport::Notifications)
|
@@ -34,18 +34,18 @@ describe Flipper::Instrumentation::LogSubscriber do
|
|
34
34
|
|
35
35
|
it "logs feature calls with result after operation" do
|
36
36
|
feature_line = find_line('Flipper feature(search) enabled? false')
|
37
|
-
feature_line.
|
37
|
+
expect(feature_line).to include('[ thing=nil ]')
|
38
38
|
end
|
39
39
|
|
40
40
|
it "logs adapter calls" do
|
41
41
|
adapter_line = find_line('Flipper feature(search) adapter(memory) get')
|
42
|
-
adapter_line.
|
43
|
-
adapter_line.
|
42
|
+
expect(adapter_line).to include('[ result={')
|
43
|
+
expect(adapter_line).to include('} ]')
|
44
44
|
end
|
45
45
|
|
46
46
|
it "logs gate calls" do
|
47
47
|
gate_line = find_line('Flipper feature(search) gate(boolean) open? false')
|
48
|
-
gate_line.
|
48
|
+
expect(gate_line).to include('[ thing=nil ]')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -59,12 +59,12 @@ describe Flipper::Instrumentation::LogSubscriber do
|
|
59
59
|
|
60
60
|
it "logs thing for feature" do
|
61
61
|
feature_line = find_line('Flipper feature(search) enabled?')
|
62
|
-
feature_line.
|
62
|
+
expect(feature_line).to include(user.inspect)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "logs thing for gate" do
|
66
66
|
gate_line = find_line('Flipper feature(search) gate(boolean) open')
|
67
|
-
gate_line.
|
67
|
+
expect(gate_line).to include(user.inspect)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -78,12 +78,12 @@ describe Flipper::Instrumentation::LogSubscriber do
|
|
78
78
|
|
79
79
|
it "logs feature calls with result in brackets" do
|
80
80
|
feature_line = find_line('Flipper feature(search) enable true')
|
81
|
-
feature_line.
|
81
|
+
expect(feature_line).to include("[ thing=#{user.inspect} gate_name=actor ]")
|
82
82
|
end
|
83
83
|
|
84
84
|
it "logs adapter value" do
|
85
85
|
adapter_line = find_line('Flipper feature(search) adapter(memory) enable')
|
86
|
-
adapter_line.
|
86
|
+
expect(adapter_line).to include("[ result=")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -95,7 +95,7 @@ describe Flipper::Instrumentation::LogSubscriber do
|
|
95
95
|
|
96
96
|
it "logs adapter calls" do
|
97
97
|
adapter_line = find_line('Flipper adapter(memory) features')
|
98
|
-
adapter_line.
|
98
|
+
expect(adapter_line).to include('[ result=')
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -2,7 +2,7 @@ require 'helper'
|
|
2
2
|
require 'flipper/adapters/memory'
|
3
3
|
require 'flipper/instrumentation/metriks'
|
4
4
|
|
5
|
-
describe Flipper::Instrumentation::MetriksSubscriber do
|
5
|
+
RSpec.describe Flipper::Instrumentation::MetriksSubscriber do
|
6
6
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
7
7
|
let(:flipper) {
|
8
8
|
Flipper.new(adapter, :instrumenter => ActiveSupport::Notifications)
|
@@ -17,43 +17,43 @@ describe Flipper::Instrumentation::MetriksSubscriber do
|
|
17
17
|
context "for enabled feature" do
|
18
18
|
it "updates feature metrics when calls happen" do
|
19
19
|
flipper[:stats].enable(user)
|
20
|
-
Metriks.timer("flipper.feature_operation.enable").count.
|
20
|
+
expect(Metriks.timer("flipper.feature_operation.enable").count).to be(1)
|
21
21
|
|
22
22
|
flipper[:stats].enabled?(user)
|
23
|
-
Metriks.timer("flipper.feature_operation.enabled").count.
|
24
|
-
Metriks.meter("flipper.feature.stats.enabled").count.
|
23
|
+
expect(Metriks.timer("flipper.feature_operation.enabled").count).to be(1)
|
24
|
+
expect(Metriks.meter("flipper.feature.stats.enabled").count).to be(1)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context "for disabled feature" do
|
29
29
|
it "updates feature metrics when calls happen" do
|
30
30
|
flipper[:stats].disable(user)
|
31
|
-
Metriks.timer("flipper.feature_operation.disable").count.
|
31
|
+
expect(Metriks.timer("flipper.feature_operation.disable").count).to be(1)
|
32
32
|
|
33
33
|
flipper[:stats].enabled?(user)
|
34
|
-
Metriks.timer("flipper.feature_operation.enabled").count.
|
35
|
-
Metriks.meter("flipper.feature.stats.disabled").count.
|
34
|
+
expect(Metriks.timer("flipper.feature_operation.enabled").count).to be(1)
|
35
|
+
expect(Metriks.meter("flipper.feature.stats.disabled").count).to be(1)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
it "updates adapter metrics when calls happen" do
|
40
40
|
flipper[:stats].enable(user)
|
41
|
-
Metriks.timer("flipper.adapter.memory.enable").count.
|
41
|
+
expect(Metriks.timer("flipper.adapter.memory.enable").count).to be(1)
|
42
42
|
|
43
43
|
flipper[:stats].enabled?(user)
|
44
|
-
Metriks.timer("flipper.adapter.memory.get").count.
|
44
|
+
expect(Metriks.timer("flipper.adapter.memory.get").count).to be(1)
|
45
45
|
|
46
46
|
flipper[:stats].disable(user)
|
47
|
-
Metriks.timer("flipper.adapter.memory.disable").count.
|
47
|
+
expect(Metriks.timer("flipper.adapter.memory.disable").count).to be(1)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "updates gate metrics when calls happen" do
|
51
51
|
flipper[:stats].enable(user)
|
52
52
|
flipper[:stats].enabled?(user)
|
53
53
|
|
54
|
-
Metriks.timer("flipper.gate_operation.boolean.open").count.
|
55
|
-
Metriks.timer("flipper.feature.stats.gate_operation.boolean.open").count.
|
56
|
-
Metriks.meter("flipper.feature.stats.gate.actor.open").count.
|
57
|
-
Metriks.meter("flipper.feature.stats.gate.boolean.closed").count.
|
54
|
+
expect(Metriks.timer("flipper.gate_operation.boolean.open").count).to be(1)
|
55
|
+
expect(Metriks.timer("flipper.feature.stats.gate_operation.boolean.open").count).to be(1)
|
56
|
+
expect(Metriks.meter("flipper.feature.stats.gate.actor.open").count).to be(1)
|
57
|
+
expect(Metriks.meter("flipper.feature.stats.gate.boolean.closed").count).to be(1)
|
58
58
|
end
|
59
59
|
end
|
@@ -2,7 +2,7 @@ require 'helper'
|
|
2
2
|
require 'flipper/adapters/memory'
|
3
3
|
require 'flipper/instrumentation/statsd'
|
4
4
|
|
5
|
-
describe Flipper::Instrumentation::StatsdSubscriber do
|
5
|
+
RSpec.describe Flipper::Instrumentation::StatsdSubscriber do
|
6
6
|
let(:statsd_client) { Statsd.new }
|
7
7
|
let(:socket) { FakeUDPSocket.new }
|
8
8
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
@@ -24,11 +24,13 @@ describe Flipper::Instrumentation::StatsdSubscriber do
|
|
24
24
|
|
25
25
|
def assert_timer(metric)
|
26
26
|
regex = /#{Regexp.escape metric}\:\d+\|ms/
|
27
|
-
socket.buffer.detect { |op| op.first =~ regex }
|
27
|
+
result = socket.buffer.detect { |op| op.first =~ regex }
|
28
|
+
expect(result).not_to be_nil
|
28
29
|
end
|
29
30
|
|
30
31
|
def assert_counter(metric)
|
31
|
-
socket.buffer.detect { |op| op.first == "#{metric}:1|c" }
|
32
|
+
result = socket.buffer.detect { |op| op.first == "#{metric}:1|c" }
|
33
|
+
expect(result).not_to be_nil
|
32
34
|
end
|
33
35
|
|
34
36
|
context "for enabled feature" do
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'flipper/instrumenters/memory'
|
3
3
|
|
4
|
-
describe Flipper::Instrumenters::Memory do
|
4
|
+
RSpec.describe Flipper::Instrumenters::Memory do
|
5
5
|
describe "#initialize" do
|
6
6
|
it "sets events to empty array" do
|
7
7
|
instrumenter = described_class.new
|
8
|
-
instrumenter.events.
|
8
|
+
expect(instrumenter.events).to eq([])
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -17,10 +17,10 @@ describe Flipper::Instrumenters::Memory do
|
|
17
17
|
block_result = :yielded
|
18
18
|
|
19
19
|
result = instrumenter.instrument(name, payload) { block_result }
|
20
|
-
result.
|
20
|
+
expect(result).to eq(block_result)
|
21
21
|
|
22
22
|
event = described_class::Event.new(name, payload, block_result)
|
23
|
-
instrumenter.events.
|
23
|
+
expect(instrumenter.events).to eq([event])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|