Class: RspecStarterStep

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_starter/step.rb

Overview

RspecStarterStep is essentially an abstract super class. It should not be instantiated directly. It primarily holds the logic for executing a Task or Command. Steps (and their subclasses) maintain three different types of options.

1. Command Options - These are specified on the command line when the bin/start_rspec command is run.
2. Step Options - These are specified inside the bin/start_rspec file when a task or command is added to the step list.
3. Step Defaults - Steps define default values when Command Options or Step Options are not given.

Direct Known Subclasses

RspecStarter::Command, RspecStarterTask

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, runner, options) ⇒ RspecStarterStep

Returns a new instance of RspecStarterStep.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rspec_starter/step.rb', line 11

def initialize(id, runner, options)
  @id = id
  initialize_name
  @runner = runner
  @options = options

  @start_time = nil
  @finish_time = nil
  @run_time = nil

  @exit_status = nil
  @successful = nil
  # This is set when the step runs
  @starting_message = nil
end

Instance Attribute Details

#exit_statusObject

Returns the value of attribute exit_status.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def exit_status
  @exit_status
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def id
  @id
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def name
  @name
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def options
  @options
end

#quietObject

Returns the value of attribute quiet.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def quiet
  @quiet
end

#run_timeObject

Returns the value of attribute run_time.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def run_time
  @run_time
end

#runnerObject

Returns the value of attribute runner.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def runner
  @runner
end

#successfulObject Also known as: successful?

Returns the value of attribute successful.



7
8
9
# File 'lib/rspec_starter/step.rb', line 7

def successful
  @successful
end

Class Method Details

.default_quietObject

Most subclasses will suppress output when they run.



72
73
74
# File 'lib/rspec_starter/step.rb', line 72

def self.default_quiet
  true
end

.default_stop_on_problemObject

Most subclasses will prefer to stop rspec_starter if they hit a problem.



77
78
79
# File 'lib/rspec_starter/step.rb', line 77

def self.default_stop_on_problem
  true
end

.provide_options_to(registrar) ⇒ Object



27
28
29
30
# File 'lib/rspec_starter/step.rb', line 27

def self.provide_options_to(registrar)
  @options_registrar = registrar
  register_options
end

.register_optionsObject

Tasks can implement this method and register options that they support.



33
34
# File 'lib/rspec_starter/step.rb', line 33

def self.register_options
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rspec_starter/step.rb', line 48

def failed?
  !@successful
end

#helpersObject



56
57
58
# File 'lib/rspec_starter/step.rb', line 56

def helpers
  RspecStarter.helpers
end

#quiet?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rspec_starter/step.rb', line 40

def quiet?
  options.quiet
end

#runObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/rspec_starter/step.rb', line 60

def run
  set_starting_message
  print_starting_message
  set_start_time
  execute_step
  set_finish_time
  set_run_time
  write_run_time
  handle_step_failure
end

#should_skip?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/rspec_starter/step.rb', line 36

def should_skip?
  false
end

#stop_on_problem?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rspec_starter/step.rb', line 44

def stop_on_problem?
  options.stop_on_problem
end

#verbose?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/rspec_starter/step.rb', line 52

def verbose?
  !quiet?
end