Class: Cucumber::Rake::Task
Overview
Defines a Rake task for running features.
The simplest use of it goes something like:
Cucumber::Rake::Task.new
This will define a task named cucumber
described as ‘Run Cucumber features’. It will use steps from ‘features/*/.rb’ and features in ‘features/*/.feature’.
To further configure the task, you can pass a block:
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format progress}
end
This task can also be configured to be run with RCov:
Cucumber::Rake::Task.new do |t|
t.rcov = true
end
See the attributes for additional configuration possibilities.
Defined Under Namespace
Classes: ForkedCucumberRunner, InProcessCucumberRunner, RCovCucumberRunner
Constant Summary collapse
- LIB =
:nodoc:
File.(File.dirname(__FILE__) + '/../..')
Instance Attribute Summary collapse
-
#binary ⇒ Object
Name of the cucumber binary to use for running features.
-
#cucumber_opts ⇒ Object
Extra options to pass to the cucumber binary.
-
#fork ⇒ Object
Whether or not to fork a new ruby interpreter.
-
#libs ⇒ Object
Directories to add to the Ruby $LOAD_PATH.
-
#profile ⇒ Object
Define what profile to be used.
-
#rcov ⇒ Object
Run cucumber with RCov? Defaults to false.
-
#rcov_opts ⇒ Object
Extra options to pass to rcov.
Instance Method Summary collapse
-
#cucumber_opts_with_profile ⇒ Object
:nodoc:.
-
#define_task ⇒ Object
:nodoc:.
-
#feature_files ⇒ Object
:nodoc:.
-
#initialize(task_name = "cucumber", desc = "Run Cucumber features") {|_self| ... } ⇒ Task
constructor
Define Cucumber Rake task.
- #make_command_line_safe(list) ⇒ Object
-
#runner(task_args = nil) ⇒ Object
:nodoc:.
Constructor Details
#initialize(task_name = "cucumber", desc = "Run Cucumber features") {|_self| ... } ⇒ Task
Define Cucumber Rake task
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/cucumber/rake/task.rb', line 121 def initialize(task_name = "cucumber", desc = "Run Cucumber features") @task_name, @desc = task_name, desc @fork = true @libs = ['lib'] @rcov_opts = %w{--rails --exclude osx\/objc,gems\/} yield self if block_given? @binary = binary.nil? ? Cucumber::BINARY : File.(binary) @libs.insert(0, LIB) if binary == Cucumber::BINARY define_task end |
Instance Attribute Details
#binary ⇒ Object
Name of the cucumber binary to use for running features. Defaults to Cucumber::BINARY
91 92 93 |
# File 'lib/cucumber/rake/task.rb', line 91 def binary @binary end |
#cucumber_opts ⇒ Object
Extra options to pass to the cucumber binary. Can be overridden by the CUCUMBER_OPTS environment variable. It’s recommended to pass an Array, but if it’s a String it will be #split by ‘ ’.
95 96 97 |
# File 'lib/cucumber/rake/task.rb', line 95 def cucumber_opts @cucumber_opts end |
#fork ⇒ Object
Whether or not to fork a new ruby interpreter. Defaults to true. You may gain some startup speed if you set it to false, but this may also cause issues with your load path and gems.
114 115 116 |
# File 'lib/cucumber/rake/task.rb', line 114 def fork @fork end |
#libs ⇒ Object
Directories to add to the Ruby $LOAD_PATH
88 89 90 |
# File 'lib/cucumber/rake/task.rb', line 88 def libs @libs end |
#profile ⇒ Object
Define what profile to be used. When used with cucumber_opts it is simply appended to it. Will be ignored when CUCUMBER_OPTS is used.
118 119 120 |
# File 'lib/cucumber/rake/task.rb', line 118 def profile @profile end |
#rcov ⇒ Object
Run cucumber with RCov? Defaults to false. If you set this to true, fork
is implicit.
102 103 104 |
# File 'lib/cucumber/rake/task.rb', line 102 def rcov @rcov end |
#rcov_opts ⇒ Object
Extra options to pass to rcov. It’s recommended to pass an Array, but if it’s a String it will be #split by ‘ ’.
106 107 108 |
# File 'lib/cucumber/rake/task.rb', line 106 def rcov_opts @rcov_opts end |
Instance Method Details
#cucumber_opts_with_profile ⇒ Object
:nodoc:
153 154 155 |
# File 'lib/cucumber/rake/task.rb', line 153 def cucumber_opts_with_profile #:nodoc: @profile ? [cucumber_opts, '--profile', @profile] : cucumber_opts end |
#define_task ⇒ Object
:nodoc:
135 136 137 138 139 140 |
# File 'lib/cucumber/rake/task.rb', line 135 def define_task #:nodoc: desc @desc task @task_name do runner.run end end |
#feature_files ⇒ Object
:nodoc:
157 158 159 |
# File 'lib/cucumber/rake/task.rb', line 157 def feature_files #:nodoc: make_command_line_safe(FileList[ ENV['FEATURE'] || [] ]) end |
#make_command_line_safe(list) ⇒ Object
161 162 163 |
# File 'lib/cucumber/rake/task.rb', line 161 def make_command_line_safe(list) list.map{|string| string.gsub(' ', '\ ')} end |
#runner(task_args = nil) ⇒ Object
:nodoc:
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/cucumber/rake/task.rb', line 142 def runner(task_args = nil) #:nodoc: cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile] if(@rcov) RCovCucumberRunner.new(libs, binary, cucumber_opts, feature_files, rcov_opts) elsif(@fork) ForkedCucumberRunner.new(libs, binary, cucumber_opts, feature_files) else InProcessCucumberRunner.new(libs, cucumber_opts, feature_files) end end |