Class: VerifyDisplayServer

Inherits:
RspecStarterTask show all
Defined in:
lib/rspec_starter/tasks/verify_display_server.rb

Overview

VerifyDisplayServer run tests on the display server. When feature tests run, they need a display server available to execute the feature tests. MacOS provides its own display server that always runs. Linux needs one installed and activated. This task is currently focused on the XVFB display server.

Instance Attribute Summary

Attributes inherited from RspecStarterStep

#exit_status, #id, #name, #options, #quiet, #run_time, #runner, #successful

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RspecStarterTask

name_for_class, register_option

Methods inherited from RspecStarterStep

default_quiet, #failed?, #helpers, #initialize, provide_options_to, #quiet?, #run, #stop_on_problem?, #verbose?

Constructor Details

This class inherits a constructor from RspecStarterStep

Class Method Details

.default_stop_on_problemObject

Let subsequent steps run if this task runs into a problem checking the display server. This value can be overridden in the applications bin/start_rspec file if the user adds ‘stop_on_problem: true’ to the task line.



15
16
17
# File 'lib/rspec_starter/tasks/verify_display_server.rb', line 15

def self.default_stop_on_problem
  false
end

.descriptionObject



5
6
7
# File 'lib/rspec_starter/tasks/verify_display_server.rb', line 5

def self.description
  "Test the installation of XVFB on Linux and ensure it is not installed on Macs."
end

.register_optionsObject



9
10
11
# File 'lib/rspec_starter/tasks/verify_display_server.rb', line 9

def self.register_options
  register_option default: false, switch: '--skip-display-server', switch_description: "DO NOT check for a display server"
end

Instance Method Details

#executeObject

rubocop:disable Style/IfUnlessModifier, Style/GuardClause



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rspec_starter/tasks/verify_display_server.rb', line 30

def execute
  # Check if a Linux user is missing XVFB. XVFB is needed to run RSpec feature tests on Linux.
  if helpers.is_linux? && helpers.xvfb_not_installed?
    problem "XVFB isn't installed; feature specs will fail."
  end

  # Check if a Mac user has XVFB installed.  Macs have their own display server so xvfb is not needed. A dev might have
  # mistakenly installed it so we can check just in case..
  if helpers.is_mac? && helpers.xvfb_installed?
    problem "XVFB is installed. (It's not needed on a Mac and may cause specs to fail.)"
  end
end

#should_skip?Boolean

The app’s bin/start_rspec file might define this task, but the user can specific –skip-display-server at run time to dynamically disable the check.

Returns:

  • (Boolean)


21
22
23
# File 'lib/rspec_starter/tasks/verify_display_server.rb', line 21

def should_skip?
  options.skip_display_server
end

#starting_messageObject



25
26
27
# File 'lib/rspec_starter/tasks/verify_display_server.rb', line 25

def starting_message
  "Verifying display server"
end