Welcome to mirror list, hosted at ThFree Co, Russian Federation.

address.rb « runtime « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 98d042fb43aca787ea4df938c8928c5928ff4122 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module QA
  module Runtime
    class Address
      attr_reader :address

      def initialize(instance, page = nil)
        @instance = instance
        @address  = host + (page.is_a?(String) ? page : page&.path)
      end

      def host
        if @instance.is_a?(Symbol)
          Runtime::Scenario.send("#{@instance}_address")
        else
          @instance.to_s
        end
      end

      def self.valid?(value)
        uri = URI.parse(value)
        uri.is_a?(URI::HTTP) && !uri.host.nil?
      rescue URI::InvalidURIError
        false
      end
    end
  end
end