Module: Geordi::FirefoxForSelenium

Extended by:
Interaction
Defined in:
lib/geordi/firefox_for_selenium.rb

Defined Under Namespace

Classes: Installer

Constant Summary collapse

FIREFOX_FOR_SELENIUM_BASE_PATH =
Pathname.new('~/bin/firefoxes').expand_path
FIREFOX_FOR_SELENIUM_PROFILE_NAME =
'firefox-for-selenium'.freeze
FIREFOX_VERSION_FILE =
Pathname.new('.firefox-version')

Class Method Summary collapse

Methods included from Interaction

announce, fail, note, note_cmd, prompt, strip_heredoc, success, warn

Class Method Details

.binary(version, name = 'firefox') ⇒ Object



40
41
42
# File 'lib/geordi/firefox_for_selenium.rb', line 40

def self.binary(version, name = 'firefox')
  path(version).join(name)
end

.install(version) ⇒ Object



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

def self.install(version)
  Installer.new(version).run
end

.path(version) ⇒ Object



36
37
38
# File 'lib/geordi/firefox_for_selenium.rb', line 36

def self.path(version)
  FIREFOX_FOR_SELENIUM_BASE_PATH.join(version)
end

.path_from_configObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/geordi/firefox_for_selenium.rb', line 17

def self.path_from_config
  version = FIREFOX_VERSION_FILE.exist? && File.read(FIREFOX_VERSION_FILE).strip

  if version && (version != 'system')
    unless FirefoxForSelenium.binary(version).exist?
      warn "Firefox #{version} not found"

      note strip_heredoc(<<-INSTRUCTIONS)
      Install it with
        geordi firefox --setup #{version}
      INSTRUCTIONS

      prompt('Run tests anyway?', 'n', /y|yes/) || raise('Cancelled.')
    end

    path(version)
  end
end

.setup_firefoxObject



44
45
46
47
48
49
50
51
# File 'lib/geordi/firefox_for_selenium.rb', line 44

def self.setup_firefox
  path = path_from_config

  if path
    ENV['PATH'] = "#{path}:#{ENV['PATH']}"
    note 'Firefox for Selenium set up'
  end
end