Class: Cucumber::Rake::Task
Overview
Defines a task for running features.
Direct Known Subclasses
Constant Summary collapse
- LIB =
File.(File.dirname(__FILE__) + '/../..')
Instance Attribute Summary collapse
-
#binary ⇒ Object
Returns the value of attribute binary.
-
#cucumber_opts ⇒ Object
Returns the value of attribute cucumber_opts.
-
#feature_list ⇒ Object
Returns the value of attribute feature_list.
-
#feature_pattern ⇒ Object
Returns the value of attribute feature_pattern.
-
#libs ⇒ Object
Returns the value of attribute libs.
-
#rcov ⇒ Object
Returns the value of attribute rcov.
-
#rcov_opts ⇒ Object
Returns the value of attribute rcov_opts.
-
#step_list ⇒ Object
Returns the value of attribute step_list.
-
#step_pattern ⇒ Object
Returns the value of attribute step_pattern.
Instance Method Summary collapse
- #arguments_for_ruby_execution(task_args = nil) ⇒ Object
- #define_task ⇒ Object
-
#feature_files(task_args = nil) ⇒ Object
:nodoc:.
-
#initialize(task_name = "features", desc = "Run Features with Cucumber") {|_self| ... } ⇒ Task
constructor
Define a task.
-
#step_files(task_args = nil) ⇒ Object
:nodoc:.
Constructor Details
#initialize(task_name = "features", desc = "Run Features with Cucumber") {|_self| ... } ⇒ Task
Define a task
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cucumber/rake/task.rb', line 20 def initialize(task_name = "features", desc = "Run Features with Cucumber") @task_name, @desc = task_name, desc @libs = [] @rcov_opts = %w{--rails --exclude osx\/objc,gems\/} yield self if block_given? @feature_pattern = "features/**/*.feature" if feature_pattern.nil? && feature_list.nil? @step_pattern = "features/**/*.rb" if step_pattern.nil? && step_list.nil? @binary = binary.nil? ? Cucumber::BINARY : File.(binary) @libs.insert(0, LIB) if binary == Cucumber::BINARY define_task end |
Instance Attribute Details
#binary ⇒ Object
Returns the value of attribute binary.
10 11 12 |
# File 'lib/cucumber/rake/task.rb', line 10 def binary @binary end |
#cucumber_opts ⇒ Object
Returns the value of attribute cucumber_opts.
15 16 17 |
# File 'lib/cucumber/rake/task.rb', line 15 def cucumber_opts @cucumber_opts end |
#feature_list ⇒ Object
Returns the value of attribute feature_list.
13 14 15 |
# File 'lib/cucumber/rake/task.rb', line 13 def feature_list @feature_list end |
#feature_pattern ⇒ Object
Returns the value of attribute feature_pattern.
14 15 16 |
# File 'lib/cucumber/rake/task.rb', line 14 def feature_pattern @feature_pattern end |
#libs ⇒ Object
Returns the value of attribute libs.
9 10 11 |
# File 'lib/cucumber/rake/task.rb', line 9 def libs @libs end |
#rcov ⇒ Object
Returns the value of attribute rcov.
16 17 18 |
# File 'lib/cucumber/rake/task.rb', line 16 def rcov @rcov end |
#rcov_opts ⇒ Object
Returns the value of attribute rcov_opts.
17 18 19 |
# File 'lib/cucumber/rake/task.rb', line 17 def rcov_opts @rcov_opts end |
#step_list ⇒ Object
Returns the value of attribute step_list.
11 12 13 |
# File 'lib/cucumber/rake/task.rb', line 11 def step_list @step_list end |
#step_pattern ⇒ Object
Returns the value of attribute step_pattern.
12 13 14 |
# File 'lib/cucumber/rake/task.rb', line 12 def step_pattern @step_pattern end |
Instance Method Details
#arguments_for_ruby_execution(task_args = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cucumber/rake/task.rb', line 43 def arguments_for_ruby_execution(task_args = nil) lib_args = ['"%s"' % libs.join(File::PATH_SEPARATOR)] cucumber_bin = ['"%s"' % binary] cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts)] step_files(task_args).each do |step_file| cuc_opts << '--require' cuc_opts << step_file end if rcov args = (['-I'] + lib_args + ['-S', 'rcov'] + rcov_opts + cucumber_bin + ['--'] + cuc_opts + feature_files(task_args)).flatten else args = (['-I'] + lib_args + cucumber_bin + cuc_opts + feature_files(task_args)).flatten end args end |
#define_task ⇒ Object
36 37 38 39 40 41 |
# File 'lib/cucumber/rake/task.rb', line 36 def define_task desc @desc task @task_name do ruby(arguments_for_ruby_execution.join(" ")) # ruby(*args) is broken on Windows end end |
#feature_files(task_args = nil) ⇒ Object
:nodoc:
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cucumber/rake/task.rb', line 63 def feature_files(task_args = nil) # :nodoc: if ENV['FEATURE'] FileList[ ENV['FEATURE'] ] else result = [] result += feature_list.to_a if feature_list result += FileList[feature_pattern].to_a if feature_pattern FileList[result] end end |
#step_files(task_args = nil) ⇒ Object
:nodoc:
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cucumber/rake/task.rb', line 74 def step_files(task_args = nil) # :nodoc: if ENV['STEPS'] FileList[ ENV['STEPS'] ] else result = [] result += Array(step_list) if step_list result += Array(FileList[step_pattern]) if step_pattern FileList[result] end end |