Class: RspecStarter::InvokeRspecStep
- Defined in:
- lib/rspec_starter/legacy/steps/invoke_rspec_step.rb
Overview
The step that actually starts the RSpec.
Instance Attribute Summary collapse
-
#rspec_exit_status ⇒ Object
readonly
Returns the value of attribute rspec_exit_status.
Attributes inherited from Step
Instance Method Summary collapse
-
#command ⇒ Object
Returns a string that will either be ‘xvfb-run bundle exec rspec’ or ‘bundle exec rspec’.
- #execute ⇒ Object
- #failed? ⇒ Boolean
- #init_rspec_options ⇒ Object
-
#initialize(defaults, runner) ⇒ InvokeRspecStep
constructor
A new instance of InvokeRspecStep.
- #should_execute? ⇒ Boolean
Methods inherited from Step
Constructor Details
#initialize(defaults, runner) ⇒ InvokeRspecStep
Returns a new instance of InvokeRspecStep.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 6 def initialize(defaults, runner) super(runner) @allow_xvfb = defaults.fetch(:allow_xvfb, true) = ["--no-xvfb"] @success_or_skipped = nil # Will be updated once step executes @rspec_exit_status = nil # Will be updated once step executes @user_wants_to_skip_xvfb = ARGV.any? { |option| option.include?("--no-xvfb") } end |
Instance Attribute Details
#rspec_exit_status ⇒ Object (readonly)
Returns the value of attribute rspec_exit_status.
4 5 6 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 4 def rspec_exit_status @rspec_exit_status end |
Instance Method Details
#command ⇒ Object
Returns a string that will either be ‘xvfb-run bundle exec rspec’ or ‘bundle exec rspec’
41 42 43 44 45 46 47 48 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 41 def command base = "bundle exec rspec" return base if @runner.is_mac? return base unless @allow_xvfb return base if @user_wants_to_skip_xvfb @runner.xvfb_installed? ? "xvfb-run #{base}" : base end |
#execute ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 31 def execute cmd = command cmd = "#{cmd} #{@rspec_options.join(' ')}" unless .empty? puts "[#{@runner.step_num}] Running specs with '#{cmd.colorize(:light_blue)}' ...\n\n" system cmd @rspec_exit_status = $CHILD_STATUS.exitstatus @success_or_skipped = true end |
#failed? ⇒ Boolean
27 28 29 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 27 def failed? !@success_or_skipped end |
#init_rspec_options ⇒ Object
17 18 19 20 21 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 17 def = [] @runner.steps.each { |step| .concat(step.) } = ARGV - .to_a end |
#should_execute? ⇒ Boolean
23 24 25 |
# File 'lib/rspec_starter/legacy/steps/invoke_rspec_step.rb', line 23 def should_execute? true end |