Class: RspecStarter::VerifyXvfbStep
- Defined in:
- lib/rspec_starter/steps/verify_xvfb_step.rb
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.
4 5 6 7 8 9 |
# File 'lib/rspec_starter/steps/verify_xvfb_step.rb', line 4 def initialize(defaults, runner) super(runner) @relevant_options << '--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.)
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rspec_starter/steps/verify_xvfb_step.rb', line 29 def execute return if should_skip? print "[#{@runner.step_num}] Verifying display server ... " if @runner.is_linux? && !@runner.xvfb_installed? print "Warning".rs_yellow return puts " (XVFB has NOT been installed on this system. If you are running feature specs, they will fail.)".rs_yellow end if @runner.is_mac? && @runner.xvfb_installed? print "Warning".rs_yellow return puts " (XVFB has been installed. This is not needed on a Mac and may cause specs to fail.)".rs_yellow end puts "Success!!".rs_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.
16 17 18 |
# File 'lib/rspec_starter/steps/verify_xvfb_step.rb', line 16 def failed? false end |
#should_execute? ⇒ Boolean
20 21 22 23 |
# File 'lib/rspec_starter/steps/verify_xvfb_step.rb', line 20 def should_execute? return false if @user_wants_to_skip_xvfb @use_xvfb end |