class Cucumber::Rake::Task
See the attributes for additional configuration possibilities.
end
t.rcov = true
Cucumber::Rake::Task.new do |t|
This task can also be configured to be run with RCov:
end
t.cucumber_opts = %w{–format progress}
Cucumber::Rake::Task.new do |t|
To further configure the task, you can pass a block:
It will use steps from ‘features/*/.rb’ and features in ‘features/*/.feature’.
This will define a task named cucumber
described as ‘Run Cucumber features’.
Cucumber::Rake::Task.new
The simplest use of it goes something like:
Defines a Rake task for running features.
def self.deprecate_accessor(attribute) #:nodoc:
TODO: remove depreated accessors for 0.4.0
def self.deprecate_accessor(attribute) #:nodoc: attr_reader attribute class_eval <<-EOF, __FILE__, __LINE__ + 1 def #{attribute}=(value) @#{attribute} = value warn("\nWARNING: Cucumber::Rake::Task##{attribute} is deprecated and will be removed in 0.4.0. Please use profiles for complex settings: http://wiki.github.com/aslakhellesoy/cucumber/using-rake#profiles\n") end EOF end
def cucumber_opts=(opts) #:nodoc:
def cucumber_opts=(opts) #:nodoc: @cucumber_opts = String === opts ? opts.split(' ') : opts end
def cucumber_opts_with_profile #:nodoc:
def cucumber_opts_with_profile #:nodoc: @profile ? [cucumber_opts, '--profile', @profile] : cucumber_opts end
def define_task #:nodoc:
def define_task #:nodoc: desc @desc task @task_name do runner.run end end
def feature_files(task_args = nil) #:nodoc:
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 result = make_command_line_safe(result) FileList[result] end end
def initialize(task_name = "cucumber", desc = "Run Cucumber features")
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? @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.expand_path(binary) @libs.insert(0, LIB) if binary == Cucumber::BINARY define_task end
def make_command_line_safe(list)
def make_command_line_safe(list) list.map{|string| string.gsub(' ', '\ ')} end
def profile=(profile) #:nodoc:
def profile=(profile) #:nodoc: @profile = profile unless feature_list # TODO: remove once we completely remove these from the rake task. @step_list = [] @feature_list = [] # Don't use accessor to avoid deprecation warning. end end
def rcov_opts=(opts) #:nodoc:
def rcov_opts=(opts) #:nodoc: @rcov_opts = String === opts ? opts.split(' ') : opts end
def runner(task_args = nil) #:nodoc:
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(task_args), rcov_opts) elsif(@fork) ForkedCucumberRunner.new(libs, binary, cucumber_opts, feature_files(task_args)) else InProcessCucumberRunner.new(libs, cucumber_opts, feature_files(task_args)) end end
def step_files(task_args = nil) #:nodoc:
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