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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: '09346724d0fd9301ab185c6b7fab44652aafb5d8'
4
- data.tar.gz: d5abd3933fec2bf06c63b37f24aa4f0cb5426af7
2
+ SHA256:
3
+ metadata.gz: cf9c70a0d36f4d97dec173bfc21738a3266700997a1af70cf3e5fac2b654c313
4
+ data.tar.gz: 7d63ce7fe82da0f11076b29498a6188691ee765bad005805bfecdea1fc022894
5
5
  SHA512:
6
- metadata.gz: 583ec0309596a8c24fb09e0df57f28850bfac7e6a6fffa77ce629cb37f1fa0af0a99384580d90c8889ac69b5c46c54c61a4e937926dab8947592673656ec4f13
7
- data.tar.gz: 0ebf9d9b58ac077a245c657d696b314dda92e5d618cc48dfea28881a16fb316d7f23833d0092f232eb526e72038d49b6baf62b355dee7f5f453301afd992b8a4
6
+ metadata.gz: 59ca9f4101ddea9d142c492052ceedc08af2a29e35601a25afd6e057e976ab4e7745ca9dac4b27156210122314df78da84ee4d42c84fd09fef32ec56a9017ae7
7
+ data.tar.gz: 9543b01d05c4e12ed4b8c0c029b3c5ff2e313b283541b47cdef0d2135c5273938d5cdcb5304981320e58a99a2399d92749729f2fc76680bbecfca60c6e938fab
@@ -1,2 +1,7 @@
1
- AllCops:
2
- TargetRubyVersion: 2.3
1
+ inherit_gem:
2
+ rubocop-govuk:
3
+ - config/default.yml
4
+
5
+ inherit_mode:
6
+ merge:
7
+ - Exclude
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.6.6
@@ -1,3 +1,8 @@
1
+ ## 2.4.2
2
+
3
+ * Updated gem dependencies and development ruby version to 2.6.6
4
+ * Fixed new rubocop violations
5
+
1
6
  ## 2.4.1
2
7
 
3
8
  * Add extra validation to ActiveSupport assertions to help debug test failures.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in govuk_ab_testing.gemspec
4
4
  gemspec
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env groovy
2
2
 
3
+ library("govuk")
4
+
3
5
  node {
4
- def govuk = load '/var/lib/jenkins/groovy_scripts/govuk_jenkinslib.groovy'
5
6
  govuk.buildProject()
6
7
  }
data/Rakefile CHANGED
@@ -1,13 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require "gem_publisher"
3
+ require "rubocop/rake_task"
4
4
 
5
+ RuboCop::RakeTask.new
5
6
  RSpec::Core::RakeTask.new(:spec)
6
7
 
7
- task :default => :spec
8
+ desc "Linting for Ruby"
9
+ task lint: :rubocop
8
10
 
9
- desc "Publish gem to RubyGems"
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]
@@ -1,7 +1,6 @@
1
- # coding: utf-8
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 'govuk_ab_testing/version'
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 = %q{Gem to help with A/B testing on the GOV.UK platform}
13
- spec.description = %q{Gem to help with A/B testing on the GOV.UK platform}
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 = ["lib"]
21
+ spec.require_paths = %w[lib]
23
22
 
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "govuk-lint", "~> 1.2.1"
27
- spec.add_development_dependency "yard", "~> 0.8"
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
@@ -1,15 +1,15 @@
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'
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(A B), control_variant: 'A')
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['Vary']
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['content'].value,
47
- dimension: tag.attributes['data-analytics-dimension'].value
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['Vary']
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['content'],
39
- dimension: tag['data-analytics-dimension']
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(capybara active_support).freeze
4
- attr_accessor :config, :acceptance_test_framework
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
- then GovukAbTesting::AcceptanceTests::Capybara
27
+ GovukAbTesting::AcceptanceTests::Capybara
28
28
  when :active_support
29
- then GovukAbTesting::AcceptanceTests::ActiveSupport
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['Vary'] = [response.headers['Vary'], ab_test.response_header].compact.join(', ')
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 + ':' + variant_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
@@ -10,6 +10,7 @@ module GovukAbTesting
10
10
 
11
11
  def assert_does_not_contain_substring(string:, substring:, error_message:)
12
12
  return if string.nil?
13
+
13
14
  expect(string).not_to include(substring), error_message
14
15
  end
15
16
 
@@ -1,3 +1,3 @@
1
1
  module GovukAbTesting
2
- VERSION = "2.4.1".freeze
2
+ VERSION = "2.4.2".freeze
3
3
  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.1
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: 2017-10-27 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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: '3.0'
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: '3.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: govuk-lint
42
+ name: rubocop-govuk
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.1
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: 1.2.1
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.8'
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.8'
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
- rubyforge_project:
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