govuk_ab_testing 1.0.2 → 1.0.3

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: 2b77eb483d96fe7cf122323876be63428b7acd7e
4
- data.tar.gz: 3dc5d675e80993664b6b17f70b59f6758150face
3
+ metadata.gz: d5f92347d47df5e991b1a05be1d87635ea828ad6
4
+ data.tar.gz: b4e1a666f672b5a06937fbc11480270c2df4c22d
5
5
  SHA512:
6
- metadata.gz: d8bb081b41576da8edcfab5f9883e037b3b48046e3c78a33df4f8cbca945a3a95b270f77f75281b973c5716574bf7b9ec488c70a051d0b12cdf6349079b5c3e5
7
- data.tar.gz: 161c6619457164b03af84126fdd8c6df48f700a82b9bbac26cfc3315f84284389f4689245f1ec20ef00392d35172c6d0b5d9264f4dfad5dd39508312e0e532df
6
+ metadata.gz: cec68a1ce03789b854cf129061f0fd85b73b816b1fbf86877d68142ccdadebf458a24f324f3ce6acd7b19f3a29addb365811299eda58abcb6c71e3fbfdf0366d
7
+ data.tar.gz: 6ece6addd993e5a06448b8e02a0db285a91ee4445cb2e0db23d3bf6aa775e88edf788d76ca770591f6137af777f198a8d54081b6bbb8817e519d6a45f0e0743a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.3
2
+
3
+ * Add more Minitest helpers with more fine-grained assertions
4
+
1
5
  ## 1.0.2
2
6
 
3
7
  * Ensure `assert_response_not_modified_for_ab_test` test helper works with all
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 " do
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")
@@ -1,3 +1,3 @@
1
1
  module GovukAbTesting
2
- VERSION = "1.0.2".freeze
2
+ VERSION = "1.0.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_ab_testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev