Class: Cukedep::CukeRunner
- Inherits:
-
Object
- Object
- Cukedep::CukeRunner
- Defined in:
- lib/cukedep/cuke-runner.rb
Overview
Purpose: to launch Cucumber in the appropriate directory and pass it command-line arguments. Responsibilities: Know how to invoke Cucumber Know the base directory Know the project's root dir
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#cucumber_opts ⇒ Object
Returns the value of attribute cucumber_opts.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#proj_dir ⇒ Object
readonly
The absolute path of the root's project directory.
-
#state ⇒ Object
readonly
The current state of the runner.
Instance Method Summary collapse
-
#after_all ⇒ Object
Event handler that is triggered after any other event.
-
#before_all ⇒ Object
Event handler that is triggered before any other event.
-
#initialize(baseDir, projectDir, aConfig) ⇒ CukeRunner
constructor
Constructor.
-
#invoke ⇒ Object
Launch Cucumber in the project directory.
- #run!(fileNames) ⇒ Object
Constructor Details
#initialize(baseDir, projectDir, aConfig) ⇒ CukeRunner
Constructor
54 55 56 57 58 59 60 61 |
# File 'lib/cukedep/cuke-runner.rb', line 54 def initialize(baseDir, projectDir, aConfig) @base_dir = baseDir @proj_dir = validated_proj_dir(projectDir) @config = aConfig @handlers = Customization.new.build_handlers(baseDir) @state = :Initialized end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
47 48 49 |
# File 'lib/cukedep/cuke-runner.rb', line 47 def base_dir @base_dir end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
48 49 50 |
# File 'lib/cukedep/cuke-runner.rb', line 48 def config @config end |
#cucumber_opts ⇒ Object
Returns the value of attribute cucumber_opts.
51 52 53 |
# File 'lib/cukedep/cuke-runner.rb', line 51 def cucumber_opts @cucumber_opts end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
49 50 51 |
# File 'lib/cukedep/cuke-runner.rb', line 49 def handlers @handlers end |
#proj_dir ⇒ Object (readonly)
The absolute path of the root's project directory
46 47 48 |
# File 'lib/cukedep/cuke-runner.rb', line 46 def proj_dir @proj_dir end |
#state ⇒ Object (readonly)
The current state of the runner.
43 44 45 |
# File 'lib/cukedep/cuke-runner.rb', line 43 def state @state end |
Instance Method Details
#after_all ⇒ Object
Event handler that is triggered after any other event. It executes first actions in the following order: Built-in save action, Custom save action Built-in delete action, Custom delete action Built-in copy action, Custom copy action Then it executes the after all hook last.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/cukedep/cuke-runner.rb', line 109 def after_all expected_state(:ReadyToRun) builtin_actions = ActionTriplet.builtin(:after_all) custom_actions = ActionTriplet.new(config.after_all_f_actions) run_triplets([builtin_actions, custom_actions]) # Execute before all hook code run_code_block @state = :Complete end |
#before_all ⇒ Object
Event handler that is triggered before any other event. It executes the before all hook first. Then it executes in the following order: Built-in save action, Custom save action Built-in delete action, Custom delete action Built-in copy action, Custom copy action
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cukedep/cuke-runner.rb', line 89 def before_all expected_state(:Initialized) # Execute before all hook code run_code_block # Execute file actions builtin_actions = ActionTriplet.builtin(:before_all) custom_actions = ActionTriplet.new(config.before_all_f_actions) run_triplets([builtin_actions, custom_actions]) @state = :ReadyToRun end |
#invoke ⇒ Object
Launch Cucumber in the project directory.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cukedep/cuke-runner.rb', line 64 def invoke = [] # TODO: retrieve Cucumber options orig_dir = Dir.getwd Dir.chdir(proj_dir) begin cuke_task = Cucumber::Rake::Task.new do |t| t.cucumber_opts = end cuke_task.runner.run rescue SystemExit => exc # Cucumber reports a failure. raise StandardError, "Cucumber exited with status #{exc.status}" ensure Dir.chdir(orig_dir) end end |
#run!(fileNames) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/cukedep/cuke-runner.rb', line 121 def run!(fileNames) expected_state(:ReadyToRun) before_each(fileNames) invoke after_each end |