Class: Utilities

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

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Utilities

Returns a new instance of Utilities.



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

def initialize
  @path = 'config/config.yml'
  @config = YAML.load_file(@path)
end

Instance Method Details

#browser=(browser) ⇒ Object



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

def browser=(browser)
  @config['browser'] = browser
  overwrite_yaml
end

#browser_options=(*opts) ⇒ Object



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

def browser_options=(*opts)
  @config['browser_options'] = opts.flatten
  overwrite_yaml
end

#delete_browser_options ⇒ Object



52
53
54
55
# File 'lib/utilities/utilities.rb', line 52

def delete_browser_options
  @config.delete('browser_options')
  overwrite_yaml
end

#download_builds(build_type) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/utilities/utilities.rb', line 71

def download_builds(build_type)
  case build_type
  when 'android'
    download_android_build
  when 'ios'
    download_ios_build
  else
    download_android_build
    download_ios_build
  end
end

#feature_path=(path) ⇒ Object



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

def feature_path=(path)
  @config['feature_path'] = path
  overwrite_yaml
end

#helper_path=(path) ⇒ Object



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

def helper_path=(path)
  @config['helper_path'] = path
  overwrite_yaml
end

#overwrite_yaml ⇒ Object



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

def overwrite_yaml
  File.open(@path, 'w') { |file| YAML.dump(@config, file) }
end

#page_path=(path) ⇒ Object



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

def page_path=(path)
  @config['page_path'] = path
  overwrite_yaml
end

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



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

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
45
# File 'lib/utilities/utilities.rb', line 42

def platform=(platform)
  @config['platform'] = platform
  overwrite_yaml
end

#run(opts = nil) ⇒ Object



57
58
59
60
# File 'lib/utilities/utilities.rb', line 57

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

#spec_path=(path) ⇒ Object



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

def spec_path=(path)
  @config['spec_path'] = path
  overwrite_yaml
end

#url=(url) ⇒ Object



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

def url=(url)
  @config['url'] = url
  overwrite_yaml
end