govuk_ab_testing 2.4.1 → 2.4.2
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 +5 -5
- data/.rubocop.yml +7 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/Jenkinsfile +2 -1
- data/Rakefile +5 -7
- data/govuk_ab_testing.gemspec +9 -11
- data/lib/govuk_ab_testing.rb +12 -12
- data/lib/govuk_ab_testing/ab_test.rb +1 -1
- data/lib/govuk_ab_testing/abstract_helpers.rb +7 -7
- data/lib/govuk_ab_testing/acceptance_tests/active_support.rb +4 -4
- data/lib/govuk_ab_testing/acceptance_tests/capybara.rb +4 -3
- data/lib/govuk_ab_testing/configuration.rb +4 -4
- data/lib/govuk_ab_testing/requested_variant.rb +5 -5
- data/lib/govuk_ab_testing/rspec_assertions.rb +1 -0
- data/lib/govuk_ab_testing/version.rb +1 -1
- metadata +20 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf9c70a0d36f4d97dec173bfc21738a3266700997a1af70cf3e5fac2b654c313
|
4
|
+
data.tar.gz: 7d63ce7fe82da0f11076b29498a6188691ee765bad005805bfecdea1fc022894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59ca9f4101ddea9d142c492052ceedc08af2a29e35601a25afd6e057e976ab4e7745ca9dac4b27156210122314df78da84ee4d42c84fd09fef32ec56a9017ae7
|
7
|
+
data.tar.gz: 9543b01d05c4e12ed4b8c0c029b3c5ff2e313b283541b47cdef0d2135c5273938d5cdcb5304981320e58a99a2399d92749729f2fc76680bbecfca60c6e938fab
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.6
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Jenkinsfile
CHANGED
data/Rakefile
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
-
require "
|
3
|
+
require "rubocop/rake_task"
|
4
4
|
|
5
|
+
RuboCop::RakeTask.new
|
5
6
|
RSpec::Core::RakeTask.new(:spec)
|
6
7
|
|
7
|
-
|
8
|
+
desc "Linting for Ruby"
|
9
|
+
task lint: :rubocop
|
8
10
|
|
9
|
-
|
10
|
-
task :publish_gem do |_t|
|
11
|
-
published_gem = GemPublisher.publish_if_updated("govuk_ab_testing.gemspec", :rubygems)
|
12
|
-
puts "Published #{published_gem}" if published_gem
|
13
|
-
end
|
11
|
+
task default: %i[lint spec]
|
data/govuk_ab_testing.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require "govuk_ab_testing/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = "govuk_ab_testing"
|
@@ -9,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
9
8
|
spec.authors = ["GOV.UK Dev"]
|
10
9
|
spec.email = ["govuk-dev@digital.cabinet-office.gov.uk"]
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
11
|
+
spec.summary = "Gem to help with A/B testing on the GOV.UK platform"
|
12
|
+
spec.description = "Gem to help with A/B testing on the GOV.UK platform"
|
14
13
|
spec.homepage = "https://github.com/alphagov/govuk_ab_testing"
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
@@ -19,11 +18,10 @@ Gem::Specification.new do |spec|
|
|
19
18
|
end
|
20
19
|
spec.bindir = "exe"
|
21
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = %w[lib]
|
23
22
|
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "govuk
|
27
|
-
spec.add_development_dependency "yard"
|
28
|
-
spec.add_development_dependency "gem_publisher", "~> 1.5.0"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "rubocop-govuk"
|
26
|
+
spec.add_development_dependency "yard"
|
29
27
|
end
|
data/lib/govuk_ab_testing.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
1
|
+
require "govuk_ab_testing/version"
|
2
|
+
require "govuk_ab_testing/configuration"
|
3
|
+
require "govuk_ab_testing/requested_variant"
|
4
|
+
require "govuk_ab_testing/ab_test"
|
5
|
+
require "govuk_ab_testing/minitest_assertions"
|
6
|
+
require "govuk_ab_testing/rspec_assertions"
|
7
|
+
require "govuk_ab_testing/abstract_helpers"
|
8
|
+
require "govuk_ab_testing/minitest_helpers"
|
9
|
+
require "govuk_ab_testing/rspec_helpers"
|
10
|
+
require "govuk_ab_testing/acceptance_tests/meta_tag"
|
11
|
+
require "govuk_ab_testing/acceptance_tests/capybara"
|
12
|
+
require "govuk_ab_testing/acceptance_tests/active_support"
|
13
13
|
|
14
14
|
module GovukAbTesting
|
15
15
|
ANALYTICS_META_TAG_SELECTOR = "meta[name='govuk:ab-test']".freeze
|
@@ -13,7 +13,7 @@ module GovukAbTesting
|
|
13
13
|
# @param allowed_variants [Array] an array of Strings representing the
|
14
14
|
# possible variants
|
15
15
|
# @param control_variant [String] the control variant (typically 'A')
|
16
|
-
def initialize(ab_test_name, dimension:, allowed_variants: %w
|
16
|
+
def initialize(ab_test_name, dimension:, allowed_variants: %w[A B], control_variant: "A")
|
17
17
|
@ab_test_name = ab_test_name
|
18
18
|
@dimension = dimension
|
19
19
|
@allowed_variants = allowed_variants
|
@@ -31,7 +31,7 @@ module GovukAbTesting
|
|
31
31
|
assert_contains_substring(
|
32
32
|
string: vary_header_value,
|
33
33
|
substring: ab_test.response_header,
|
34
|
-
error_message: <<-ERROR
|
34
|
+
error_message: <<-ERROR,
|
35
35
|
The 'Vary' header is not being set for the '#{ab_test.name}' A/B test.
|
36
36
|
You will need to use GovukAbTesting::RequestedVariant#configure_response in your controller:
|
37
37
|
|
@@ -46,7 +46,7 @@ module GovukAbTesting
|
|
46
46
|
assert_does_not_contain_substring(
|
47
47
|
string: vary_header,
|
48
48
|
substring: ab_test_name,
|
49
|
-
error_message: <<-ERROR
|
49
|
+
error_message: <<-ERROR,
|
50
50
|
The 'Vary' header is being set by A/B test '#{ab_test_name}' on a page that should not be modified
|
51
51
|
by the A/B test. Check for incorrect usage of GovukAbTesting::RequestedVariant#configure_response
|
52
52
|
in your controller.
|
@@ -63,7 +63,7 @@ module GovukAbTesting
|
|
63
63
|
|
64
64
|
assert_is_empty(
|
65
65
|
enumerable: ab_test_meta_tags,
|
66
|
-
error_message: <<-ERROR
|
66
|
+
error_message: <<-ERROR,
|
67
67
|
Found the '#{ab_test_name}' A/B testing meta tag on a page that should not be modified by
|
68
68
|
the A/B test.
|
69
69
|
|
@@ -81,7 +81,7 @@ module GovukAbTesting
|
|
81
81
|
assert_has_size(
|
82
82
|
enumerable: ab_test_meta_tags,
|
83
83
|
size: 1,
|
84
|
-
error_message: <<-ERROR
|
84
|
+
error_message: <<-ERROR,
|
85
85
|
Incorrect number of analytics meta tags on the page for A/B test '#{ab_test.name}'.
|
86
86
|
You may need to check usage of GovukAbTesting::RequestedVariant#analytics_meta_tag in your template(s):
|
87
87
|
|
@@ -96,7 +96,7 @@ module GovukAbTesting
|
|
96
96
|
assert_is_equal(
|
97
97
|
expected: expected_metatag_content,
|
98
98
|
actual: meta_tag.content,
|
99
|
-
error_message: <<-ERROR
|
99
|
+
error_message: <<-ERROR,
|
100
100
|
The analytics meta tag content for A/B test '#{ab_test.name}' does not match the expected value.
|
101
101
|
You may need to use GovukAbTesting::RequestedVariant#analytics_meta_tag in your template(s):
|
102
102
|
|
@@ -107,7 +107,7 @@ module GovukAbTesting
|
|
107
107
|
|
108
108
|
assert_not_blank(
|
109
109
|
string: meta_tag.dimension,
|
110
|
-
error_message: <<-ERROR
|
110
|
+
error_message: <<-ERROR,
|
111
111
|
The meta tag dimension for the '#{ab_test_name}' A/B test is blank.
|
112
112
|
ERROR
|
113
113
|
)
|
@@ -116,7 +116,7 @@ module GovukAbTesting
|
|
116
116
|
assert_is_equal(
|
117
117
|
expected: ab_test.dimension.to_s,
|
118
118
|
actual: meta_tag.dimension.to_s,
|
119
|
-
error_message: <<-ERROR
|
119
|
+
error_message: <<-ERROR,
|
120
120
|
The analytics meta tag for the '#{ab_test.name}' A/B test does not match the expected value.
|
121
121
|
ERROR
|
122
122
|
)
|
@@ -26,7 +26,7 @@ module GovukAbTesting
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def vary_header
|
29
|
-
response.headers[
|
29
|
+
response.headers["Vary"]
|
30
30
|
end
|
31
31
|
|
32
32
|
def analytics_meta_tags_for_test(ab_test_name)
|
@@ -35,7 +35,7 @@ module GovukAbTesting
|
|
35
35
|
|
36
36
|
def analytics_meta_tags
|
37
37
|
if scope.response.body.empty?
|
38
|
-
raise "Cannot find response body. If this is an RSpec Rails test, "
|
38
|
+
raise "Cannot find response body. If this is an RSpec Rails test, " \
|
39
39
|
"check that 'render_views' is being called."
|
40
40
|
end
|
41
41
|
|
@@ -43,8 +43,8 @@ module GovukAbTesting
|
|
43
43
|
|
44
44
|
tags.map do |tag|
|
45
45
|
MetaTag.new(
|
46
|
-
content: tag.attributes[
|
47
|
-
dimension: tag.attributes[
|
46
|
+
content: tag.attributes["content"].value,
|
47
|
+
dimension: tag.attributes["data-analytics-dimension"].value,
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
@@ -7,6 +7,7 @@ module GovukAbTesting
|
|
7
7
|
unless scope.respond_to?(:page)
|
8
8
|
raise "Page is not defined, are you using capybara?"
|
9
9
|
end
|
10
|
+
|
10
11
|
@capybara_page = scope.page
|
11
12
|
@request_headers = {}
|
12
13
|
end
|
@@ -23,7 +24,7 @@ module GovukAbTesting
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def vary_header(*)
|
26
|
-
capybara_page.response_headers[
|
27
|
+
capybara_page.response_headers["Vary"]
|
27
28
|
end
|
28
29
|
|
29
30
|
def analytics_meta_tags_for_test(ab_test_name)
|
@@ -35,8 +36,8 @@ module GovukAbTesting
|
|
35
36
|
|
36
37
|
tags.map do |tag|
|
37
38
|
MetaTag.new(
|
38
|
-
content: tag[
|
39
|
-
dimension: tag[
|
39
|
+
content: tag["content"],
|
40
|
+
dimension: tag["data-analytics-dimension"],
|
40
41
|
)
|
41
42
|
end
|
42
43
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module GovukAbTesting
|
2
2
|
class Configuration
|
3
|
-
VALID_FRAMEWORKS = %i
|
4
|
-
attr_accessor :config
|
3
|
+
VALID_FRAMEWORKS = %i[capybara active_support].freeze
|
4
|
+
attr_accessor :config
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@config = {}
|
@@ -24,9 +24,9 @@ module GovukAbTesting
|
|
24
24
|
@framework_class ||= begin
|
25
25
|
case config[:acceptance_test_framework]
|
26
26
|
when :capybara
|
27
|
-
|
27
|
+
GovukAbTesting::AcceptanceTests::Capybara
|
28
28
|
when :active_support
|
29
|
-
|
29
|
+
GovukAbTesting::AcceptanceTests::ActiveSupport
|
30
30
|
else
|
31
31
|
raise "Invalid framework #{acceptance_test_framework}"
|
32
32
|
end
|
@@ -56,17 +56,17 @@ module GovukAbTesting
|
|
56
56
|
#
|
57
57
|
# @param [ApplicationController::Response] the `response` in the controller
|
58
58
|
def configure_response(response)
|
59
|
-
response.headers[
|
59
|
+
response.headers["Vary"] = [response.headers["Vary"], ab_test.response_header].compact.join(", ")
|
60
60
|
end
|
61
61
|
|
62
62
|
# HTML meta tag used to track the results of your experiment
|
63
63
|
#
|
64
64
|
# @return [String]
|
65
65
|
def analytics_meta_tag
|
66
|
-
'<meta name="govuk:ab-test" '
|
67
|
-
'content="' + ab_test.meta_tag_name +
|
68
|
-
'data-analytics-dimension="' + @dimension.to_s + '" '
|
69
|
-
'data-allowed-variants="' + ab_test.allowed_variants.join(
|
66
|
+
'<meta name="govuk:ab-test" ' \
|
67
|
+
'content="' + ab_test.meta_tag_name + ":" + variant_name + '" ' \
|
68
|
+
'data-analytics-dimension="' + @dimension.to_s + '" ' \
|
69
|
+
'data-allowed-variants="' + ab_test.allowed_variants.join(",") + '">'
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
metadata
CHANGED
@@ -1,85 +1,71 @@
|
|
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.2
|
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: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: govuk
|
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: '0'
|
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: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: gem_publisher
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.5.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.5.0
|
68
|
+
version: '0'
|
83
69
|
description: Gem to help with A/B testing on the GOV.UK platform
|
84
70
|
email:
|
85
71
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -132,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
118
|
- !ruby/object:Gem::Version
|
133
119
|
version: '0'
|
134
120
|
requirements: []
|
135
|
-
|
136
|
-
rubygems_version: 2.6.13
|
121
|
+
rubygems_version: 3.0.3
|
137
122
|
signing_key:
|
138
123
|
specification_version: 4
|
139
124
|
summary: Gem to help with A/B testing on the GOV.UK platform
|