Class: RspecStarter::InvokeRspecStep
- Defined in:
- lib/rspec_starter/steps/invoke_rspec_step.rb
Instance Attribute Summary
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
4 5 6 7 8 9 10 11 |
# File 'lib/rspec_starter/steps/invoke_rspec_step.rb', line 4 def initialize(defaults, runner) super(runner) @allow_xvfb = defaults.fetch(:allow_xvfb, true) @relevant_options = ["--no-xvfb"] @success_or_skipped = nil # Will be updated once step executes @user_wants_to_skip_xvfb = ARGV.any? { |option| option.include?("--no-xvfb") } end |
Instance Method Details
#command ⇒ Object
Returns a string that will either be ‘xvfb-run bundle exec rspec’ or ‘bundle exec rspec’
36 37 38 39 40 41 42 |
# File 'lib/rspec_starter/steps/invoke_rspec_step.rb', line 36 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
27 28 29 30 31 32 33 |
# File 'lib/rspec_starter/steps/invoke_rspec_step.rb', line 27 def execute cmd = command cmd = "#{cmd} #{@rspec_options.join(' ')}" unless @rspec_options.empty? puts "[#{@runner.step_num}] Running specs with '#{cmd.rs_yellow}' ...\n\n" system cmd @success_or_skipped = true end |
#failed? ⇒ Boolean
23 24 25 |
# File 'lib/rspec_starter/steps/invoke_rspec_step.rb', line 23 def failed? !@success_or_skipped end |
#init_rspec_options ⇒ Object
13 14 15 16 17 |
# File 'lib/rspec_starter/steps/invoke_rspec_step.rb', line 13 def = [] @runner.steps.each { |step| .concat(step.) } @rspec_options = ARGV - .to_a end |
#should_execute? ⇒ Boolean
19 20 21 |
# File 'lib/rspec_starter/steps/invoke_rspec_step.rb', line 19 def should_execute? true end |