govuk_ab_testing 2.4.0 → 2.4.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 +8 -0
- data/README.md +38 -11
- data/lib/govuk_ab_testing/acceptance_tests/active_support.rb +5 -0
- data/lib/govuk_ab_testing/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09346724d0fd9301ab185c6b7fab44652aafb5d8'
|
4
|
+
data.tar.gz: d5abd3933fec2bf06c63b37f24aa4f0cb5426af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 583ec0309596a8c24fb09e0df57f28850bfac7e6a6fffa77ce629cb37f1fa0af0a99384580d90c8889ac69b5c46c54c61a4e937926dab8947592673656ec4f13
|
7
|
+
data.tar.gz: 0ebf9d9b58ac077a245c657d696b314dda92e5d618cc48dfea28881a16fb316d7f23833d0092f232eb526e72038d49b6baf62b355dee7f5f453301afd992b8a4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 2.4.1
|
2
|
+
|
3
|
+
* Add extra validation to ActiveSupport assertions to help debug test failures.
|
4
|
+
In order to make assertions about the `meta` tags, the view must be rendered
|
5
|
+
in the test. RSpec Rails tests do not do this by default, so you need to call
|
6
|
+
`render_views` explicitly. Without this check, tests fail with a cryptic error
|
7
|
+
message "undefined method 'document' for nil:NilClass".
|
8
|
+
|
1
9
|
## 2.4.0
|
2
10
|
|
3
11
|
* Add two new optional parameters to `GovukAbTesting::AbTest`:
|
data/README.md
CHANGED
@@ -50,12 +50,20 @@ Now, let's say you have this controller:
|
|
50
50
|
# app/controllers/party_controller.rb
|
51
51
|
class PartyController < ApplicationController
|
52
52
|
def show
|
53
|
-
ab_test = GovukAbTesting::AbTest.new(
|
53
|
+
ab_test = GovukAbTesting::AbTest.new(
|
54
|
+
"your_ab_test_name",
|
55
|
+
dimension: 300,
|
56
|
+
allowed_variants: ['NoChange', 'LongTitle', 'ShortTitle'],
|
57
|
+
control_variant: 'NoChange'
|
58
|
+
)
|
54
59
|
@requested_variant = ab_test.requested_variant(request.headers)
|
55
60
|
@requested_variant.configure_response(response)
|
56
61
|
|
57
|
-
|
58
|
-
|
62
|
+
case true
|
63
|
+
when @requested_variant.variant?('LongTitle')
|
64
|
+
render "show_template_with_long_title"
|
65
|
+
when @requested_variant.variant?('ShortTitle')
|
66
|
+
render "show_template_with_short_title"
|
59
67
|
else
|
60
68
|
render "show"
|
61
69
|
end
|
@@ -63,7 +71,11 @@ class PartyController < ApplicationController
|
|
63
71
|
end
|
64
72
|
```
|
65
73
|
|
66
|
-
|
74
|
+
In this example, we are running a multivariate test with 3 options being
|
75
|
+
tested: the existing version (control), and two title changes. The minimum
|
76
|
+
number of variants in any test should be two.
|
77
|
+
|
78
|
+
Then, add this to your layouts, so that we have a meta tag that can be picked up
|
67
79
|
by the extension and analytics.
|
68
80
|
|
69
81
|
```html
|
@@ -73,6 +85,9 @@ by the extension and analytics.
|
|
73
85
|
</head>
|
74
86
|
```
|
75
87
|
|
88
|
+
The analytics meta tag will include the allowed variants so the extension knows
|
89
|
+
which variants to suggest the user.
|
90
|
+
|
76
91
|
#### Test helpers
|
77
92
|
|
78
93
|
##### Minitest
|
@@ -157,7 +172,7 @@ end
|
|
157
172
|
##### RSpec
|
158
173
|
|
159
174
|
It is also possible to use `with_variant` and all the individual setup and
|
160
|
-
assertions steps in RSpec tests. Here is an example of a
|
175
|
+
assertions steps in RSpec tests. Here is an example of a Capybara feature file:
|
161
176
|
|
162
177
|
```ruby
|
163
178
|
# spec/features/ab_testing_spec.rb
|
@@ -175,18 +190,30 @@ feature "Viewing a page with an A/B test" do
|
|
175
190
|
end
|
176
191
|
```
|
177
192
|
|
193
|
+
And here is an RSpec controller test:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
# spec/controllers/some_controller_spec.rb
|
197
|
+
describe SomeController, type :controller do
|
198
|
+
include GovukAbTesting::RspecHelpers
|
199
|
+
|
200
|
+
# RSpec doesn't render views for controller specs by default
|
201
|
+
render_views
|
202
|
+
|
203
|
+
it "should render the B version of the page" do
|
204
|
+
with_variant your_ab_test_name: 'B' do
|
205
|
+
get :index
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
```
|
210
|
+
|
178
211
|
As with the `minitest` version, you can also pass in the following options to
|
179
212
|
`with_variant`:
|
180
213
|
|
181
214
|
- `assert_meta_tag: false`
|
182
215
|
- `dimension: <number>`
|
183
216
|
|
184
|
-
### Current limitations
|
185
|
-
|
186
|
-
This library assumes we are only using one A/B test per page. The acceptance
|
187
|
-
test classes look for only one analytics' meta tag and will fail in the presence
|
188
|
-
of more than one.
|
189
|
-
|
190
217
|
### Running the test suite
|
191
218
|
|
192
219
|
`bundle exec rake`
|
@@ -34,6 +34,11 @@ module GovukAbTesting
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def analytics_meta_tags
|
37
|
+
if scope.response.body.empty?
|
38
|
+
raise "Cannot find response body. If this is an RSpec Rails test, " +
|
39
|
+
"check that 'render_views' is being called."
|
40
|
+
end
|
41
|
+
|
37
42
|
tags = scope.css_select(ANALYTICS_META_TAG_SELECTOR)
|
38
43
|
|
39
44
|
tags.map do |tag|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_ab_testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.6.
|
136
|
+
rubygems_version: 2.6.13
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Gem to help with A/B testing on the GOV.UK platform
|