Class: RspecStarter::VerifyXvfbStep
- Defined in:
- lib/rspec_starter/legacy/steps/verify_xvfb_step.rb
Overview
The step that makes sure XVFB is installed on the system. When feature tests run, they need a display server to power the browsr that will execute the feature tests. MacOS provides its own display server that always runs. Linux needs one installed and activated.
Instance Attribute Summary
Attributes inherited from Step
Instance Method Summary collapse
-
#execute ⇒ Object
There are two cases we need to be checked 1.
-
#failed? ⇒ Boolean
This step doesn’t really fail.
-
#initialize(defaults, runner) ⇒ VerifyXvfbStep
constructor
A new instance of VerifyXvfbStep.
- #should_execute? ⇒ Boolean
Methods inherited from Step
Constructor Details
#initialize(defaults, runner) ⇒ VerifyXvfbStep
Returns a new instance of VerifyXvfbStep.
6 7 8 9 10 11 12 |
# File 'lib/rspec_starter/legacy/steps/verify_xvfb_step.rb', line 6 def initialize(defaults, runner) super(runner) << '--no-xvfb' @use_xvfb = defaults.fetch(:use_xvfb, true) @user_wants_to_skip_xvfb = ARGV.any? { |option| option.include?("--no-xvfb") } end |
Instance Method Details
#execute ⇒ Object
There are two cases we need to be checked
1. A Linux user does not have xvfb installed (xvfb is needed to run RSpec feature tests on Linux).
2. A Mac User has xvfb installed. (Macs have their own display server so xvfb is not needed; a dev might have mistakenly
tried to install, so we can check for it just in case.)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rspec_starter/legacy/steps/verify_xvfb_step.rb', line 33 def execute return if should_skip? print "[#{@runner.step_num}] Verifying display server ... " if @runner.is_linux? && !@runner.xvfb_installed? return puts "Warning (XVFB is not installed. Feature specs will fail.)".colorize(:yellow) end if @runner.is_mac? && @runner.xvfb_installed? return puts "Warning (XVFB has been installed. It's not needed on a Mac and may cause specs to fail.)".colorize(:yellow) end puts "Success!!".colorize(:green) end |
#failed? ⇒ Boolean
This step doesn’t really fail. Although there may be problems with how XVFB is installed, it’s only a problem when the user is trying to run feature specs. The user may be in a situation where he’s working on Linux and XVFB isn’t installed, but he may not have any feature specs to run. We shouldn’t block the tests from running just because XVFB hasn’t been installed yet. So we just warn the user and put the ball in his court. If he’s running feature specs with a busted XVFB setup, we have at least warned him.
19 20 21 |
# File 'lib/rspec_starter/legacy/steps/verify_xvfb_step.rb', line 19 def failed? false end |
#should_execute? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/rspec_starter/legacy/steps/verify_xvfb_step.rb', line 23 def should_execute? return false if @user_wants_to_skip_xvfb @use_xvfb end |