determinator 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/docs/local_development.md +23 -5
- data/lib/determinator/version.rb +1 -1
- data/lib/rspec/determinator.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d743c707c8d4b9e9e28c122aee5bd965ab3e097d
|
4
|
+
data.tar.gz: 540858ec639b34a39ceeef760ee51831f4c5a4a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14391fb80975ee14cea5982fb345507794c5c07824f750bbc972b21dd847df5872ecbb054842fe8ceea42944c2aa7f2e696cb8d176dc904a03ff77ff150f2b45
|
7
|
+
data.tar.gz: 6819a9318fbce45ff3b096299d104872ad16b3cfb267277050ea3480423ba180f3881484b6b1fd5a2c7ab78d424e43fd8b3690057d7962405283dcde85f31027
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,8 @@ variant = determinator.which_variant(
|
|
43
43
|
)
|
44
44
|
```
|
45
45
|
|
46
|
+
Writing tests? Check out the [Local development](docs/local_development.md) docs to see examples of `RSpec::Determinator` to help you mock your Feature Flags and Experiments.
|
47
|
+
|
46
48
|
## Installation
|
47
49
|
|
48
50
|
Determinator requires your application to be subscribed to the a `features` topic via Routemaster.
|
data/docs/local_development.md
CHANGED
@@ -15,14 +15,18 @@ RSpec.describe YourClass, :determinator_support do
|
|
15
15
|
# This allows testing of the experiment being in a specific variant
|
16
16
|
forced_determination(:experiment_name, 'variant_a')
|
17
17
|
|
18
|
-
it "should respond in a way that is defined by variant_a"
|
18
|
+
it "should respond in a way that is defined by variant_a" do
|
19
|
+
# … etc
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
context "when the actor is not in the experiment" do
|
22
24
|
# This allows testing of the experiment being off
|
23
25
|
forced_determination(:experiment_name, false)
|
24
26
|
|
25
|
-
it "should respond in a way that is defined by being out of the experiment"
|
27
|
+
it "should respond in a way that is defined by being out of the experiment" do
|
28
|
+
# … etc
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
context "when the actor is not from France" do
|
@@ -30,7 +34,18 @@ RSpec.describe YourClass, :determinator_support do
|
|
30
34
|
# This allows testing of target group constraint functionality
|
31
35
|
forced_determination(:experiment_name, 'variant_b', only_for: { country: 'fr' })
|
32
36
|
|
33
|
-
it "should respond in a way that is defined by being out of the experiment"
|
37
|
+
it "should respond in a way that is defined by being out of the experiment" do
|
38
|
+
# … etc
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when the constraints are defined dynamically" do
|
43
|
+
forced_determination(:experiment_name, 'variant_b', only_for: constraints)
|
44
|
+
let(:constraints) { { employee: true } }
|
45
|
+
|
46
|
+
it "should respond in a way that shows employees the experiment" do
|
47
|
+
# … etc
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
51
|
context "when the actor has a specified id" do
|
@@ -38,11 +53,14 @@ RSpec.describe YourClass, :determinator_support do
|
|
38
53
|
# This allows testing of override functionality
|
39
54
|
forced_determination(:experiment_name, 'variant_b', only_for: { id: '123' })
|
40
55
|
|
41
|
-
it "should respond in a way that is defined by variant_b"
|
42
|
-
|
56
|
+
it "should respond in a way that is defined by variant_b" do
|
57
|
+
# … etc
|
58
|
+
end
|
43
59
|
end
|
44
60
|
```
|
45
61
|
|
62
|
+
Note that you can use Symbols for either the constraint declaration (`only_for`) or the outcome declaration and that variable or method will be called and the result used for that value. This is particularly helpful for examples which use the `let` scope declarations for cleaner tests.
|
63
|
+
|
46
64
|
## Fake Florence for local execution
|
47
65
|
|
48
66
|
[Fake Florence](https://github.com/deliveroo/fake_florence) is a command line utility which operates a determinator compatible server and provides tooling for easy editing of feature flags and experiments.
|
data/lib/determinator/version.rb
CHANGED
data/lib/rspec/determinator.rb
CHANGED
@@ -12,11 +12,23 @@ module RSpec
|
|
12
12
|
end
|
13
13
|
|
14
14
|
module DSL
|
15
|
-
|
15
|
+
# Ensure that for the duration of the example all determinations made for the given experiment or feature flag
|
16
|
+
# will have the given outcome (but only if the constraints specified are met exactly).
|
17
|
+
#
|
18
|
+
# If `outcome` or `only_for` are Symbols then the example-scoped variable of that name will be referenced (ie. those
|
19
|
+
# variables created by `let` declarations)
|
20
|
+
#
|
21
|
+
# @params name [#to_s] The name of the Feature Flag or Experiment to mock
|
22
|
+
# @params outcome [Boolean,String,Symbol] The outcome which should be supplied. Will look up an example variable if a Symbol is given.
|
23
|
+
# @params :only_for [Hash,Symbol] The constraints that must be matched exactly in order for the determination to be applied.
|
24
|
+
def forced_determination(name, outcome, only_for: {})
|
16
25
|
before do
|
26
|
+
outcome = send(outcome) if outcome.is_a?(Symbol)
|
27
|
+
only_for = send(only_for) if only_for.is_a?(Symbol)
|
28
|
+
|
17
29
|
fake_determinator.mock_result(
|
18
30
|
name,
|
19
|
-
|
31
|
+
outcome,
|
20
32
|
only_for: only_for
|
21
33
|
)
|
22
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: determinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Hastings-Spital
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: routemaster-drain
|