Sha256: f770756eaddca840fd40c4f530beb4f314006848ad7b1731e057ee4436f8a202
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module GovukAbTesting module AcceptanceTests class ActiveSupport attr_reader :request_headers, :scope def initialize(scope) @scope = scope @request_headers = {} if request.nil? raise "Couldn't find '@request' defined, are you using ActiveSupport test cases?" end end def request @scope.instance_variable_get(:@request) end def response @scope.instance_variable_get(:@response) end def set_header(name, value) request.headers[name] = value @request_headers[name] = value end def vary_header response.headers['Vary'] end def analytics_meta_tags_for_test(ab_test_name) analytics_meta_tags.select { |tag| tag.for_ab_test?(ab_test_name) } end def analytics_meta_tags if scope.response.body.empty? raise "Cannot find response body. If this is an RSpec Rails test, " + "check that 'render_views' is being called." end tags = scope.css_select(ANALYTICS_META_TAG_SELECTOR) tags.map do |tag| MetaTag.new( content: tag.attributes['content'].value, dimension: tag.attributes['data-analytics-dimension'].value ) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
govuk_ab_testing-2.4.1 | lib/govuk_ab_testing/acceptance_tests/active_support.rb |