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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e34898ef5ebd55998c28389b7644266fff00ca90
4
- data.tar.gz: 01497458ea7daf49b59fb70c9214e7a2ae4c14cf
3
+ metadata.gz: d743c707c8d4b9e9e28c122aee5bd965ab3e097d
4
+ data.tar.gz: 540858ec639b34a39ceeef760ee51831f4c5a4a3
5
5
  SHA512:
6
- metadata.gz: 8ec544cbdd744dc830e2432ee98af864361427ea543883b4db6227d72fcdf61ab2345bba6abd36df5abccacd67f99f2f4524a85338e5eea8fac5dbca32f2afe5
7
- data.tar.gz: c68d088da9eba87eba25e3ecc89ae20122801a9be93c183c18c96c2e4b71b0081fc2d2e1b4c450400dd8945d4f1f54c47b3c00a32f60ad31af04a8d7da6b5b22
6
+ metadata.gz: 14391fb80975ee14cea5982fb345507794c5c07824f750bbc972b21dd847df5872ecbb054842fe8ceea42944c2aa7f2e696cb8d176dc904a03ff77ff150f2b45
7
+ data.tar.gz: 6819a9318fbce45ff3b096299d104872ad16b3cfb267277050ea3480423ba180f3881484b6b1fd5a2c7ab78d424e43fd8b3690057d7962405283dcde85f31027
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.11.1 (2017-10-27)
2
+
3
+ Feature:
4
+ - Allows the use of example-scoped variables for outcomes and constraints in `RSpec::Determinator`'s mocks. (#36)
5
+
1
6
  # v0.11.0 (2017-10-13)
2
7
 
3
8
  Bug fix:
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.
@@ -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
- end
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.
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '0.11.0'
2
+ VERSION = '0.11.1'
3
3
  end
@@ -12,11 +12,23 @@ module RSpec
12
12
  end
13
13
 
14
14
  module DSL
15
- def forced_determination(name, result, only_for: {})
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
- result,
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: routemaster-drain