Class: Geordi::Cucumber

Inherits:
Object
  • Object
show all
Includes:
Interaction
Defined in:
lib/geordi/cucumber.rb

Constant Summary collapse

VNC_DISPLAY =
':17'
VNC_SERVER_COMMAND =
"vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024"
VNC_VIEWER_COMMAND =
"vncviewer #{VNC_DISPLAY}"
VNC_ENV_VARIABLES =
%w[DISPLAY BROWSER LAUNCHY_BROWSER]

Instance Method Summary collapse

Methods included from Interaction

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

Instance Method Details

#launch_vnc_viewerObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/geordi/cucumber.rb', line 32

def launch_vnc_viewer
  fork {
    error = capture_stderr do
      system(VNC_VIEWER_COMMAND)
    end
    unless $?.success?
      if $?.exitstatus == 127
        fail 'VNC viewer not found. Install it with `geordi vnc --setup`.'
      else
        note 'VNC viewer could not be opened:'
        puts error
        puts
      end
    end
  }
end

#restore_envObject



49
50
51
52
53
# File 'lib/geordi/cucumber.rb', line 49

def restore_env
  VNC_ENV_VARIABLES.each do |variable|
    ENV[variable] = ENV["OUTER_#{variable}"]
  end
end

#run(files, cucumber_options, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/geordi/cucumber.rb', line 18

def run(files, cucumber_options, options = {})
  self.argv = files + cucumber_options

  consolidate_rerun_txt_files
  show_features_to_run
  setup_vnc

  command = use_parallel_tests?(options) ? parallel_execution_command : serial_execution_command
  note_cmd(command) if options[:verbose]

  puts # Make newline
  system command # Util.system! would reset the Firefox PATH
end

#setup_vncObject



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/geordi/cucumber.rb', line 55

def setup_vnc
  if try_and_start_vnc
    VNC_ENV_VARIABLES.each do |variable|
      ENV["OUTER_#{variable}"] = ENV[variable] if ENV[variable]
    end
    ENV["BROWSER"] = ENV["LAUNCHY_BROWSER"] = File.expand_path('../../../bin/launchy_browser', __FILE__)
    ENV["DISPLAY"] = VNC_DISPLAY

    note 'VNC is ready to hold Selenium test browsers. Use `geordi vnc` to view them.'
  end
end