Module: Utilities

Defined in:
lib/utilities/utilities.rb

Class Method Summary collapse

Class Method Details

.batch_update(**settings) ⇒ Object

Set multiple config keys in a single YAML write. Usage: Utilities.batch_update(browser: ‘chrome’, timeout: 30)



67
68
69
70
71
# File 'lib/utilities/utilities.rb', line 67

def batch_update(**settings)
  reload_config
  settings.each { |key, value| @config[key.to_s] = value }
  overwrite_yaml
end

.browser=(browser) ⇒ Object



9
10
11
# File 'lib/utilities/utilities.rb', line 9

def browser=(browser)
  set('browser', browser.to_s.delete_prefix(':'))
end

.browser_options=(opts) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/utilities/utilities.rb', line 46

def browser_options=(opts)
  reload_config
  browser_name = @config['browser'] || 'chrome'
  @config['browser_arguments'] ||= {}
  @config['browser_arguments'][browser_name] = Array(opts).flatten
  overwrite_yaml
end

.delete_browser_optionsObject



54
55
56
57
58
59
# File 'lib/utilities/utilities.rb', line 54

def delete_browser_options
  reload_config
  browser_name = @config['browser'] || 'chrome'
  @config['browser_arguments']&.delete(browser_name)
  overwrite_yaml
end

.feature_path=(path) ⇒ Object



21
22
23
# File 'lib/utilities/utilities.rb', line 21

def feature_path=(path)
  set('feature_path', path)
end

.headless=(enabled) ⇒ Object



61
62
63
# File 'lib/utilities/utilities.rb', line 61

def headless=(enabled)
  set('headless', enabled)
end

.helper_path=(path) ⇒ Object



25
26
27
# File 'lib/utilities/utilities.rb', line 25

def helper_path=(path)
  set('helper_path', path)
end

.page_path=(path) ⇒ Object



13
14
15
# File 'lib/utilities/utilities.rb', line 13

def page_path=(path)
  set('page_path', path)
end

.parallel_run(opts = nil, _settings = nil) ⇒ Object



78
79
80
81
# File 'lib/utilities/utilities.rb', line 78

def parallel_run(opts = nil, _settings = nil)
  command = File.directory?('spec') ? 'parallel_rspec spec/' : 'parallel_cucumber features'
  system "#{command} #{opts}"
end

.platform=(platform) ⇒ Object



42
43
44
# File 'lib/utilities/utilities.rb', line 42

def platform=(platform)
  set('platform', platform)
end

.run(opts = nil) ⇒ Object



73
74
75
76
# File 'lib/utilities/utilities.rb', line 73

def run(opts = nil)
  command = File.directory?('spec') ? 'rspec spec/' : 'cucumber features'
  system "#{command} #{opts}"
end

.spec_path=(path) ⇒ Object



17
18
19
# File 'lib/utilities/utilities.rb', line 17

def spec_path=(path)
  set('spec_path', path)
end

.timeout=(seconds) ⇒ Object



33
34
35
# File 'lib/utilities/utilities.rb', line 33

def timeout=(seconds)
  set('timeout', seconds.to_i)
end

.url=(url) ⇒ Object



29
30
31
# File 'lib/utilities/utilities.rb', line 29

def url=(url)
  set('url', url)
end

.viewport=(dimensions) ⇒ Object



37
38
39
40
# File 'lib/utilities/utilities.rb', line 37

def viewport=(dimensions)
  width, height = dimensions.split('x').map(&:to_i)
  set('viewport', { 'width' => width, 'height' => height })
end