Class: GovukAbTesting::AcceptanceTests::Capybara
- Inherits:
-
Object
- Object
- GovukAbTesting::AcceptanceTests::Capybara
- Defined in:
- lib/govuk_ab_testing/acceptance_tests/capybara.rb
Instance Attribute Summary collapse
-
#capybara_page ⇒ Object
readonly
Returns the value of attribute capybara_page.
-
#request_headers ⇒ Object
readonly
Returns the value of attribute request_headers.
Instance Method Summary collapse
- #analytics_meta_tags ⇒ Object
- #analytics_meta_tags_for_test(ab_test_name) ⇒ Object
-
#initialize(scope) ⇒ Capybara
constructor
A new instance of Capybara.
- #request ⇒ Object
- #set_header(name, value) ⇒ Object
- #vary_header ⇒ Object
Constructor Details
#initialize(scope) ⇒ Capybara
Returns a new instance of Capybara.
6 7 8 9 10 11 12 13 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 6 def initialize(scope) unless scope.respond_to?(:page) raise "Page is not defined, are you using capybara?" end @capybara_page = scope.page @request_headers = {} end |
Instance Attribute Details
#capybara_page ⇒ Object (readonly)
Returns the value of attribute capybara_page.
4 5 6 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 4 def @capybara_page end |
#request_headers ⇒ Object (readonly)
Returns the value of attribute request_headers.
4 5 6 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 4 def request_headers @request_headers end |
Instance Method Details
#analytics_meta_tags ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 34 def = .all(ANALYTICS_META_TAG_SELECTOR, visible: :all) .map do |tag| MetaTag.new( content: tag["content"], ) end end |
#analytics_meta_tags_for_test(ab_test_name) ⇒ Object
30 31 32 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 30 def (ab_test_name) .select { |tag| tag.for_ab_test?(ab_test_name) } end |
#request ⇒ Object
15 16 17 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 15 def request @capybara_page end |
#set_header(name, value) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 19 def set_header(name, value) .driver.[:headers] ||= {} .driver.[:headers][name] = value .driver.header(name, value) @request_headers[name] = value end |
#vary_header ⇒ Object
26 27 28 |
# File 'lib/govuk_ab_testing/acceptance_tests/capybara.rb', line 26 def vary_header(*) .response_headers["Vary"] end |