summaryrefslogtreecommitdiff
path: root/qa/qa/runtime
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-07 14:55:51 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-07 14:55:51 +0100
commitb80dc88441ff251096d23e596f8933cab072912f (patch)
treef1240415772171469c7446a712601f6dcfc44fe3 /qa/qa/runtime
parent86aa7ac13bc256b6e35d6e02773598ca01a552b9 (diff)
downloadgitlab-ce-b80dc88441ff251096d23e596f8933cab072912f.tar.gz
Decouple subject's address from page objects in QA
Diffstat (limited to 'qa/qa/runtime')
-rw-r--r--qa/qa/runtime/browser.rb32
1 files changed, 25 insertions, 7 deletions
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb
index 16fa3a1bd23..e05dd9612df 100644
--- a/qa/qa/runtime/browser.rb
+++ b/qa/qa/runtime/browser.rb
@@ -12,14 +12,25 @@ module QA
self.class.configure!
end
- def visit(page, &block)
- Browser::Session.new(page).tap do |session|
+ ##
+ # Visit a page that belongs to a GitLab instance under given address.
+ #
+ # Example:
+ #
+ # visit(:gitlab, Page::Main::Login)
+ # visit('http://gitlab.example/users/sign_in')
+ #
+ # In case of an address that is a symbol we will try to guess address
+ # based on `Runtime::Scenario#something_address`.
+ #
+ def visit(address, page, &block)
+ Browser::Session.new(address, page).tap do |session|
session.perform(&block)
end
end
- def self.visit(page, &block)
- new.visit(page, &block)
+ def self.visit(address, page, &block)
+ new.visit(address, page, &block)
end
def self.configure!
@@ -52,10 +63,17 @@ module QA
class Session
include Capybara::DSL
- attr_reader :address
+ def initialize(instance, page = nil)
+ @instance = instance
+ @address = host + page&.path
+ end
- def initialize(page)
- @address = page.is_a?(String) ? page : page.address
+ def host
+ if @instance.is_a?(Symbol)
+ Runtime::Scenario.send("#{@instance}_address")
+ else
+ @instance.to_s
+ end
end
def perform(&block)