govuk_ab_testing 1.0.2 → 1.0.3
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/README.md +21 -1
- data/lib/govuk_ab_testing/minitest_helpers.rb +12 -0
- data/lib/govuk_ab_testing/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5f92347d47df5e991b1a05be1d87635ea828ad6
|
4
|
+
data.tar.gz: b4e1a666f672b5a06937fbc11480270c2df4c22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec68a1ce03789b854cf129061f0fd85b73b816b1fbf86877d68142ccdadebf458a24f324f3ce6acd7b19f3a29addb365811299eda58abcb6c71e3fbfdf0366d
|
7
|
+
data.tar.gz: 6ece6addd993e5a06448b8e02a0db285a91ee4445cb2e0db23d3bf6aa775e88edf788d76ca770591f6137af777f198a8d54081b6bbb8817e519d6a45f0e0743a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -127,7 +127,7 @@ To test the negative case in which a page is unaffected by the A/B test:
|
|
127
127
|
class PartyControllerTest < ActionController::TestCase
|
128
128
|
include GovukAbTesting::MinitestHelpers
|
129
129
|
|
130
|
-
should "show the original
|
130
|
+
should "show the original" do
|
131
131
|
setup_ab_variant("your_ab_test_name", "B") # optionally pass in a analytics dimension as the third argument
|
132
132
|
|
133
133
|
get :show
|
@@ -137,6 +137,26 @@ class PartyControllerTest < ActionController::TestCase
|
|
137
137
|
end
|
138
138
|
```
|
139
139
|
|
140
|
+
There are some more fine-grained assertions which you can use to test a page
|
141
|
+
with A/B variants which should be cached separately, but which should be
|
142
|
+
excluded from the analytics:
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
# test/controllers/party_controller_test.rb
|
146
|
+
class PartyControllerTest < ActionController::TestCase
|
147
|
+
include GovukAbTesting::MinitestHelpers
|
148
|
+
|
149
|
+
should "cache each variant but not add analytics" do
|
150
|
+
setup_ab_variant("your_ab_test_name", "B")
|
151
|
+
|
152
|
+
get :show
|
153
|
+
|
154
|
+
assert_response_is_cached_by_variant("your_ab_test_name")
|
155
|
+
assert_page_not_tracked_in_ab_test
|
156
|
+
end
|
157
|
+
end
|
158
|
+
```
|
159
|
+
|
140
160
|
##### RSpec
|
141
161
|
|
142
162
|
It is also possible to use `with_variant` in RSpec tests. Here is an example of
|
@@ -55,10 +55,22 @@ module GovukAbTesting
|
|
55
55
|
acceptance_test_framework.set_header(ab_test.request_header, variant)
|
56
56
|
end
|
57
57
|
|
58
|
+
def assert_response_is_cached_by_variant(ab_test_name)
|
59
|
+
ab_test = GovukAbTesting::AbTest.new(ab_test_name, dimension: 123)
|
60
|
+
|
61
|
+
vary_header_value = acceptance_test_framework.vary_header(response)
|
62
|
+
assert_match ab_test.response_header, vary_header_value,
|
63
|
+
"You probably forgot to use `configure_response`"
|
64
|
+
end
|
65
|
+
|
58
66
|
def assert_response_not_modified_for_ab_test
|
59
67
|
assert_nil acceptance_test_framework.vary_header(response),
|
60
68
|
"`Vary` header is being added to a page which should not be modified by the A/B test"
|
61
69
|
|
70
|
+
assert_page_not_tracked_in_ab_test
|
71
|
+
end
|
72
|
+
|
73
|
+
def assert_page_not_tracked_in_ab_test
|
62
74
|
meta_tags = acceptance_test_framework.analytics_meta_tags
|
63
75
|
assert_equal(0, meta_tags.count,
|
64
76
|
"A/B meta tag is being added to a page which should not be modified by the A/B test")
|