Class: SimpleSauce::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_sauce/options.rb

Constant Summary collapse

W3C =
%i[browser_name platform_name browser_version].freeze
SAUCE =
%i[access_key appium_version avoid_proxy build capture_html chromedriver_version command_timeout
crmuxdriver_version custom_data disable_popup_handler extended_debugging firefox_adapter_version
firefox_profile_url idle_timeout iedriver_version max_duration name parent_tunnel passed prerun
prevent_requeue priority proxy_host public record_logs record_screenshots record_video
restricted_public_info screen_resolution selenium_version source tags time_zone tunnel_identifier
username video_upload_on_pass capture_performance].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Options

Returns a new instance of Options.



20
21
22
23
24
25
26
# File 'lib/simple_sauce/options.rb', line 20

def initialize(**opts)
  @browser_name = 'chrome'
  @platform_name = 'Windows 10'
  @browser_version = 'latest'

  create_variables(SAUCE + W3C, opts)
end

Class Method Details

.camel_case(str) ⇒ Object



6
7
8
# File 'lib/simple_sauce/options.rb', line 6

def camel_case(str)
  str.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
end

Instance Method Details

#capabilitiesObject Also known as: as_json



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/simple_sauce/options.rb', line 28

def capabilities
  caps = W3C.each_with_object({}) do |key, hash|
    value = send(key)
    hash[self.class.camel_case(key)] = value if value
  end
  caps['sauce:options'] = {}
  SAUCE.each do |key|
    value = send(key)
    caps['sauce:options'][self.class.camel_case(key)] = value unless value.nil?
  end
  caps
end