govuk_ab_testing 2.4.2 → 3.0.0
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/.github/dependabot.yml +10 -0
- data/.github/workflows/ci.yml +45 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +12 -0
- data/README.md +94 -86
- data/govuk_ab_testing.gemspec +3 -2
- data/lib/govuk_ab_testing/ab_test.rb +3 -9
- data/lib/govuk_ab_testing/abstract_helpers.rb +7 -25
- data/lib/govuk_ab_testing/acceptance_tests/active_support.rb +0 -1
- data/lib/govuk_ab_testing/acceptance_tests/capybara.rb +0 -1
- data/lib/govuk_ab_testing/acceptance_tests/meta_tag.rb +2 -3
- data/lib/govuk_ab_testing/configuration.rb +8 -10
- data/lib/govuk_ab_testing/minitest_assertions.rb +1 -1
- data/lib/govuk_ab_testing/requested_variant.rb +8 -8
- data/lib/govuk_ab_testing/version.rb +1 -1
- metadata +11 -10
- data/Jenkinsfile +0 -7
- /data/{LICENSE.txt → LICENCE} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d473c839937d932bfad0e7dc33673c907f47dedffdf15d1b5bc4bd2d9c61df1
|
4
|
+
data.tar.gz: 4ba58b2b6b499b8b670fff033740d3efb8ce421a0d5f561a58bb4b028968fd36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e5f893dcd4b96da54646fa5f951f7949f1d3e499cc51fe84b22b3869f281857ca74259ee927a4337a50a34dc50b6ef24460f578ed3af38c26b0c8dde0cad366
|
7
|
+
data.tar.gz: b438372d3a2a309acbe83dde157cd09a5a9f857ddf03ad28009e10cd212cb4034716b831fa87f41c301ee892329f9c5e3f47d8d23eb49dd34e2f3a9135f6b752
|
@@ -0,0 +1,45 @@
|
|
1
|
+
on: [push, pull_request]
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
codeql-sast:
|
5
|
+
name: CodeQL SAST scan
|
6
|
+
uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main
|
7
|
+
permissions:
|
8
|
+
security-events: write
|
9
|
+
|
10
|
+
dependency-review:
|
11
|
+
name: Dependency Review scan
|
12
|
+
uses: alphagov/govuk-infrastructure/.github/workflows/dependency-review.yml@main
|
13
|
+
|
14
|
+
# This matrix job runs the test suite against multiple Ruby versions
|
15
|
+
test_matrix:
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [3.1, 3.2, 3.3]
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v4
|
23
|
+
- uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
26
|
+
bundler-cache: true
|
27
|
+
- run: bundle exec rake
|
28
|
+
|
29
|
+
# Branch protection rules cannot directly depend on status checks from matrix jobs.
|
30
|
+
# So instead we define `test` as a dummy job which only runs after the preceding `test_matrix` checks have passed.
|
31
|
+
# Solution inspired by: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
|
32
|
+
test:
|
33
|
+
needs: test_matrix
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
steps:
|
36
|
+
- run: echo "All matrix tests have passed 🚀"
|
37
|
+
|
38
|
+
publish:
|
39
|
+
needs: test
|
40
|
+
if: ${{ github.ref == 'refs/heads/main' }}
|
41
|
+
permissions:
|
42
|
+
contents: write
|
43
|
+
uses: alphagov/govuk-infrastructure/.github/workflows/publish-rubygem.yml@main
|
44
|
+
secrets:
|
45
|
+
GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 3.0.0
|
2
|
+
|
3
|
+
* Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1
|
4
|
+
* **BREAKING CHANGE** No longer allow a GA custom dimension to be passed
|
5
|
+
when creating a GovukAbTesting::AbTest object. The dimension parameter
|
6
|
+
needs to be removed.
|
7
|
+
|
8
|
+
## 2.4.3
|
9
|
+
|
10
|
+
* Updated gem dependencies and development ruby version to 3.0.5
|
11
|
+
* Fixed new rubocop violations
|
12
|
+
|
1
13
|
## 2.4.2
|
2
14
|
|
3
15
|
* Updated gem dependencies and development ruby version to 2.6.6
|
data/README.md
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem to help with A/B testing on the GOV.UK platform.
|
4
4
|
|
5
|
-
##
|
6
|
-
|
7
|
-
### Installation
|
5
|
+
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
@@ -16,35 +14,26 @@ And then execute:
|
|
16
14
|
|
17
15
|
$ bundle
|
18
16
|
|
19
|
-
|
17
|
+
## Pre-requisites
|
20
18
|
|
21
19
|
Before starting this, you'll need to:
|
22
20
|
|
23
|
-
- [
|
24
|
-
-
|
21
|
+
- [Read the documentation](https://docs.publishing.service.gov.uk/manual/ab-testing.html) for an overview on how a/b testing works on GOV.UK.
|
22
|
+
- The cookie and header name in [govuk-cdn-config](https://github.com/alphagov/govuk-cdn-config/blob/master/ab_tests/ab_tests.yaml) must match the test name parameter that you pass to the Gem. The cookie name is case-sensitive.
|
25
23
|
|
26
|
-
|
24
|
+
## Usage
|
27
25
|
|
28
|
-
|
29
|
-
2. A HTML meta tag that will be used to measure the results, and which specifies
|
30
|
-
the dimension to use in Google Analytics
|
31
|
-
3. A response HTTP header that tells Fastly you're doing an A/B test
|
26
|
+
### Outline
|
32
27
|
|
33
|
-
|
34
|
-
supports both Capybara and ActiveSupport. In order to configure it, add this to
|
35
|
-
your test helper file:
|
28
|
+
To enable testing in the app, your Rails app needs:
|
36
29
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
```
|
30
|
+
1. [Some piece of logic to be A/B tested](#1-example-ab-test-logic)
|
31
|
+
2. [A response HTTP header that tells Fastly you're doing an A/B test](#2-http-response-header-to-fastly)
|
32
|
+
3. [A HTML meta tag that will be used to measure the results in Google Analytics](#3-add-html-metatag-tags-to-your-layouts)
|
42
33
|
|
43
|
-
|
44
|
-
test cases. If we use ActiveSupport, the gem expects `@request` to be defined in
|
45
|
-
the scope of the test cases.
|
34
|
+
### 1. Example A/B test logic
|
46
35
|
|
47
|
-
|
36
|
+
Let's say you have this controller:
|
48
37
|
|
49
38
|
```ruby
|
50
39
|
# app/controllers/party_controller.rb
|
@@ -52,7 +41,6 @@ class PartyController < ApplicationController
|
|
52
41
|
def show
|
53
42
|
ab_test = GovukAbTesting::AbTest.new(
|
54
43
|
"your_ab_test_name",
|
55
|
-
dimension: 300,
|
56
44
|
allowed_variants: ['NoChange', 'LongTitle', 'ShortTitle'],
|
57
45
|
control_variant: 'NoChange'
|
58
46
|
)
|
@@ -75,8 +63,13 @@ In this example, we are running a multivariate test with 3 options being
|
|
75
63
|
tested: the existing version (control), and two title changes. The minimum
|
76
64
|
number of variants in any test should be two.
|
77
65
|
|
78
|
-
|
79
|
-
|
66
|
+
### 2. HTTP response header to Fastly
|
67
|
+
|
68
|
+
The `configure_response` method used in the example in `step 1` sends the response header. The header helps Fastly to understand which variant was returned to the user and cache appropriately.
|
69
|
+
|
70
|
+
### 3. Add HTML metatag tags to your layouts
|
71
|
+
|
72
|
+
This is for the extension and analytics.
|
80
73
|
|
81
74
|
```html
|
82
75
|
<!-- application.html.erb -->
|
@@ -86,11 +79,75 @@ by the extension and analytics.
|
|
86
79
|
```
|
87
80
|
|
88
81
|
The analytics meta tag will include the allowed variants so the extension knows
|
89
|
-
which variants to suggest the user.
|
82
|
+
which variants to suggest to the user.
|
90
83
|
|
91
|
-
|
84
|
+
## Running the test suite for the gem
|
92
85
|
|
93
|
-
|
86
|
+
`bundle exec rake`
|
87
|
+
|
88
|
+
## Acceptance testing
|
89
|
+
|
90
|
+
Start by defining which acceptance testing framework you will use. This gem
|
91
|
+
supports both Capybara and ActiveSupport. In order to configure it, add this to
|
92
|
+
your test helper file:
|
93
|
+
|
94
|
+
```
|
95
|
+
GovukAbTesting.configure do |config|
|
96
|
+
config.acceptance_test_framework = :capybara # or :active_support
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
If we use capybara, the gem expects `page` to be defined in the scope of the
|
101
|
+
test cases. If we use ActiveSupport, the gem expects `@request` to be defined in
|
102
|
+
the scope of the test cases.
|
103
|
+
|
104
|
+
### Test helpers
|
105
|
+
|
106
|
+
#### RSpec
|
107
|
+
|
108
|
+
It is also possible to use `with_variant` and all the individual setup and
|
109
|
+
assertions steps in RSpec tests. Here is an example of a Capybara feature file:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# spec/features/ab_testing_spec.rb
|
113
|
+
feature "Viewing a page with an A/B test" do
|
114
|
+
include GovukAbTesting::RspecHelpers
|
115
|
+
|
116
|
+
scenario "viewing the B version of the page" do
|
117
|
+
with_variant your_ab_test_name: 'B' do
|
118
|
+
visit root_path
|
119
|
+
|
120
|
+
expect(page).to have_breadcrumbs
|
121
|
+
expect(page).to have_beta_label
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
And here is an RSpec controller test:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
# spec/controllers/some_controller_spec.rb
|
131
|
+
describe SomeController, type :controller do
|
132
|
+
include GovukAbTesting::RspecHelpers
|
133
|
+
|
134
|
+
# RSpec doesn't render views for controller specs by default
|
135
|
+
render_views
|
136
|
+
|
137
|
+
it "should render the B version of the page" do
|
138
|
+
with_variant your_ab_test_name: 'B' do
|
139
|
+
get :index
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
```
|
144
|
+
|
145
|
+
As with the `minitest` version, you can also pass in the following options to
|
146
|
+
`with_variant`:
|
147
|
+
|
148
|
+
- `assert_meta_tag: false`
|
149
|
+
|
150
|
+
#### Minitest
|
94
151
|
|
95
152
|
The most common usage of an A/B test is to serve two different variants of the
|
96
153
|
same page. In this situation, you can test the controller using `with_variant`.
|
@@ -140,7 +197,7 @@ class PartyControllerTest < ActionController::TestCase
|
|
140
197
|
include GovukAbTesting::MinitestHelpers
|
141
198
|
|
142
199
|
should "show the original" do
|
143
|
-
setup_ab_variant("your_ab_test_name", "B")
|
200
|
+
setup_ab_variant("your_ab_test_name", "B")
|
144
201
|
|
145
202
|
get :show
|
146
203
|
|
@@ -169,71 +226,22 @@ class PartyControllerTest < ActionController::TestCase
|
|
169
226
|
end
|
170
227
|
```
|
171
228
|
|
172
|
-
|
173
|
-
|
174
|
-
It is also possible to use `with_variant` and all the individual setup and
|
175
|
-
assertions steps in RSpec tests. Here is an example of a Capybara feature file:
|
176
|
-
|
177
|
-
```ruby
|
178
|
-
# spec/features/ab_testing_spec.rb
|
179
|
-
feature "Viewing a page with an A/B test" do
|
180
|
-
include GovukAbTesting::RspecHelpers
|
181
|
-
|
182
|
-
scenario "viewing the B version of the page" do
|
183
|
-
with_variant your_ab_test_name: 'B' do
|
184
|
-
visit root_path
|
185
|
-
|
186
|
-
expect(page).to have_breadcrumbs
|
187
|
-
expect(page).to have_beta_label
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
```
|
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
|
-
|
211
|
-
As with the `minitest` version, you can also pass in the following options to
|
212
|
-
`with_variant`:
|
229
|
+
## API documentation
|
213
230
|
|
214
|
-
|
215
|
-
- `dimension: <number>`
|
231
|
+
See [RubyDoc](http://www.rubydoc.info/gems/govuk_ab_testing) for documentation including all of the assertions for tests.
|
216
232
|
|
217
|
-
|
233
|
+
To run a Yard server locally to preview documentation, run:
|
218
234
|
|
219
|
-
|
235
|
+
$ bundle exec yard server --reload
|
220
236
|
|
221
|
-
|
237
|
+
## Checking your A/B test in a browser
|
222
238
|
|
223
239
|
If you want to test this behaviour in a browser then you should use the
|
224
|
-
[GOV.UK Toolkit
|
240
|
+
[GOV.UK Toolkit browser extension](https://github.com/alphagov/govuk-browser-extension).
|
225
241
|
|
226
242
|
This detects when you have a test running on a page and enables you to choose
|
227
243
|
between variants.
|
228
244
|
|
229
|
-
### Documentation
|
230
|
-
|
231
|
-
See [RubyDoc](http://www.rubydoc.info/gems/govuk_ab_testing) for some limited documentation.
|
232
|
-
|
233
|
-
To run a Yard server locally to preview documentation, run:
|
234
|
-
|
235
|
-
$ bundle exec yard server --reload
|
236
|
-
|
237
245
|
## Licence
|
238
246
|
|
239
|
-
[MIT License](LICENCE
|
247
|
+
[MIT License](LICENCE)
|
data/govuk_ab_testing.gemspec
CHANGED
@@ -12,8 +12,9 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "Gem to help with A/B testing on the GOV.UK platform"
|
13
13
|
spec.homepage = "https://github.com/alphagov/govuk_ab_testing"
|
14
14
|
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.1"
|
15
16
|
|
16
|
-
spec.files
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
20
|
spec.bindir = "exe"
|
@@ -22,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
22
23
|
|
23
24
|
spec.add_development_dependency "rake"
|
24
25
|
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "rubocop-govuk"
|
26
|
+
spec.add_development_dependency "rubocop-govuk", "5.0.2"
|
26
27
|
spec.add_development_dependency "yard"
|
27
28
|
end
|
@@ -1,21 +1,15 @@
|
|
1
1
|
module GovukAbTesting
|
2
2
|
class AbTest
|
3
|
-
attr_reader :ab_test_name
|
4
|
-
attr_reader :dimension
|
5
|
-
attr_reader :allowed_variants
|
6
|
-
attr_reader :control_variant
|
3
|
+
attr_reader :ab_test_name, :allowed_variants, :control_variant
|
7
4
|
|
8
5
|
alias_method :name, :ab_test_name
|
9
6
|
|
10
7
|
# @param request [String] the name of the A/B test
|
11
|
-
# @param dimension [Integer] the dimension registered with Google Analytics
|
12
|
-
# for this specific A/B test
|
13
8
|
# @param allowed_variants [Array] an array of Strings representing the
|
14
9
|
# possible variants
|
15
10
|
# @param control_variant [String] the control variant (typically 'A')
|
16
|
-
def initialize(ab_test_name,
|
11
|
+
def initialize(ab_test_name, allowed_variants: %w[A B], control_variant: "A")
|
17
12
|
@ab_test_name = ab_test_name
|
18
|
-
@dimension = dimension
|
19
13
|
@allowed_variants = allowed_variants
|
20
14
|
@control_variant = control_variant
|
21
15
|
end
|
@@ -23,7 +17,7 @@ module GovukAbTesting
|
|
23
17
|
# @param request [ActionDispatch::Http::Headers] the `request.headers` in
|
24
18
|
# the controller.
|
25
19
|
def requested_variant(request_headers)
|
26
|
-
RequestedVariant.new(self, request_headers
|
20
|
+
RequestedVariant.new(self, request_headers)
|
27
21
|
end
|
28
22
|
|
29
23
|
# Internal name of the header
|
@@ -6,26 +6,25 @@ module GovukAbTesting
|
|
6
6
|
|
7
7
|
def with_variant(args)
|
8
8
|
ab_test_name, variant = args.first
|
9
|
-
dimension = args[:dimension]
|
10
9
|
|
11
|
-
setup_ab_variant(ab_test_name, variant
|
10
|
+
setup_ab_variant(ab_test_name, variant)
|
12
11
|
|
13
12
|
yield
|
14
13
|
|
15
14
|
assert_response_is_cached_by_variant(ab_test_name)
|
16
15
|
|
17
16
|
unless args[:assert_meta_tag] == false
|
18
|
-
assert_page_tracked_in_ab_test(ab_test_name, variant
|
17
|
+
assert_page_tracked_in_ab_test(ab_test_name, variant)
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
def setup_ab_variant(ab_test_name, variant
|
23
|
-
ab_test = AbTest.new(ab_test_name
|
21
|
+
def setup_ab_variant(ab_test_name, variant)
|
22
|
+
ab_test = AbTest.new(ab_test_name)
|
24
23
|
acceptance_test_framework.set_header(ab_test.request_header, variant)
|
25
24
|
end
|
26
25
|
|
27
26
|
def assert_response_is_cached_by_variant(ab_test_name)
|
28
|
-
ab_test = AbTest.new(ab_test_name
|
27
|
+
ab_test = AbTest.new(ab_test_name)
|
29
28
|
vary_header_value = acceptance_test_framework.vary_header
|
30
29
|
|
31
30
|
assert_contains_substring(
|
@@ -72,8 +71,8 @@ module GovukAbTesting
|
|
72
71
|
)
|
73
72
|
end
|
74
73
|
|
75
|
-
def assert_page_tracked_in_ab_test(ab_test_name, variant
|
76
|
-
ab_test = AbTest.new(ab_test_name
|
74
|
+
def assert_page_tracked_in_ab_test(ab_test_name, variant)
|
75
|
+
ab_test = AbTest.new(ab_test_name)
|
77
76
|
|
78
77
|
ab_test_meta_tags =
|
79
78
|
acceptance_test_framework.analytics_meta_tags_for_test(ab_test.name)
|
@@ -104,23 +103,6 @@ module GovukAbTesting
|
|
104
103
|
|
105
104
|
ERROR
|
106
105
|
)
|
107
|
-
|
108
|
-
assert_not_blank(
|
109
|
-
string: meta_tag.dimension,
|
110
|
-
error_message: <<-ERROR,
|
111
|
-
The meta tag dimension for the '#{ab_test_name}' A/B test is blank.
|
112
|
-
ERROR
|
113
|
-
)
|
114
|
-
|
115
|
-
unless ab_test.dimension.nil?
|
116
|
-
assert_is_equal(
|
117
|
-
expected: ab_test.dimension.to_s,
|
118
|
-
actual: meta_tag.dimension.to_s,
|
119
|
-
error_message: <<-ERROR,
|
120
|
-
The analytics meta tag for the '#{ab_test.name}' A/B test does not match the expected value.
|
121
|
-
ERROR
|
122
|
-
)
|
123
|
-
end
|
124
106
|
end
|
125
107
|
end
|
126
108
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module GovukAbTesting
|
2
2
|
module AcceptanceTests
|
3
3
|
class MetaTag
|
4
|
-
attr_reader :content
|
4
|
+
attr_reader :content
|
5
5
|
|
6
|
-
def initialize(content
|
6
|
+
def initialize(content:)
|
7
7
|
@content = content
|
8
|
-
@dimension = dimension
|
9
8
|
end
|
10
9
|
|
11
10
|
def for_ab_test?(ab_test_name)
|
@@ -21,16 +21,14 @@ module GovukAbTesting
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def framework_class
|
24
|
-
@framework_class ||=
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
24
|
+
@framework_class ||= case config[:acceptance_test_framework]
|
25
|
+
when :capybara
|
26
|
+
GovukAbTesting::AcceptanceTests::Capybara
|
27
|
+
when :active_support
|
28
|
+
GovukAbTesting::AcceptanceTests::ActiveSupport
|
29
|
+
else
|
30
|
+
raise "Invalid framework #{acceptance_test_framework}"
|
31
|
+
end
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
@@ -17,7 +17,7 @@ module GovukAbTesting
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def assert_is_empty(enumerable:, error_message:)
|
20
|
-
assert_has_size(enumerable
|
20
|
+
assert_has_size(enumerable:, size: 0, error_message:)
|
21
21
|
end
|
22
22
|
|
23
23
|
def assert_not_blank(string:, error_message:)
|
@@ -5,12 +5,9 @@ module GovukAbTesting
|
|
5
5
|
# @param ab_test [AbTest] the A/B test being performed
|
6
6
|
# @param request_headers [ActionDispatch::Http::Headers] the
|
7
7
|
# `request.headers` in the controller.
|
8
|
-
|
9
|
-
# for this specific A/B test
|
10
|
-
def initialize(ab_test, request_headers, dimension)
|
8
|
+
def initialize(ab_test, request_headers)
|
11
9
|
@ab_test = ab_test
|
12
10
|
@request_headers = request_headers
|
13
|
-
@dimension = dimension
|
14
11
|
end
|
15
12
|
|
16
13
|
# Get the bucket this user is in
|
@@ -63,10 +60,13 @@ module GovukAbTesting
|
|
63
60
|
#
|
64
61
|
# @return [String]
|
65
62
|
def analytics_meta_tag
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
tag = <<~HTML
|
64
|
+
<meta name="govuk:ab-test"
|
65
|
+
content="#{ab_test.meta_tag_name}:#{variant_name}"
|
66
|
+
data-allowed-variants="#{ab_test.allowed_variants.join(',')}">
|
67
|
+
HTML
|
68
|
+
|
69
|
+
tag.gsub(/\n/, "")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
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:
|
4
|
+
version: 3.0.0
|
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:
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rubocop-govuk
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.0.2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 5.0.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +73,15 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/dependabot.yml"
|
77
|
+
- ".github/workflows/ci.yml"
|
76
78
|
- ".gitignore"
|
77
79
|
- ".rspec"
|
78
80
|
- ".rubocop.yml"
|
79
81
|
- ".ruby-version"
|
80
82
|
- CHANGELOG.md
|
81
83
|
- Gemfile
|
82
|
-
-
|
83
|
-
- LICENSE.txt
|
84
|
+
- LICENCE
|
84
85
|
- README.md
|
85
86
|
- Rakefile
|
86
87
|
- bin/console
|
@@ -111,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
112
|
requirements:
|
112
113
|
- - ">="
|
113
114
|
- !ruby/object:Gem::Version
|
114
|
-
version: '
|
115
|
+
version: '3.1'
|
115
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
117
|
requirements:
|
117
118
|
- - ">="
|
118
119
|
- !ruby/object:Gem::Version
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
122
|
+
rubygems_version: 3.5.17
|
122
123
|
signing_key:
|
123
124
|
specification_version: 4
|
124
125
|
summary: Gem to help with A/B testing on the GOV.UK platform
|
data/Jenkinsfile
DELETED
/data/{LICENSE.txt → LICENCE}
RENAMED
File without changes
|