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 = “–format progress”
Cucumber::Rake::Task.new do |t|
To further configure the task, you can pass a block:
Cucumber’. It will use steps from ‘features/*/.rb’ and features in ‘features/*/.feature’.
This will create a task named ‘features’ described as ‘Run Features with
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("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") end EOF end
def arguments_for_ruby_execution(task_args = nil) # :nodoc:
def arguments_for_ruby_execution(task_args = nil) # :nodoc: lib_args = ['"%s"' % libs.join(File::PATH_SEPARATOR)] cucumber_bin = ['"%s"' % binary] cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts_with_profile)] 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
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 ruby(arguments_for_ruby_execution.join(" ")) # ruby(*args) is broken on Windows 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 FileList[result] end end
def initialize(task_name = "features", desc = "Run Features with Cucumber")
def initialize(task_name = "features", desc = "Run Features with Cucumber") @task_name, @desc = task_name, desc @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 profile=(profile)
def profile=(profile) @profile = profile unless feature_list @feature_list = [] # Don't use accessor to avoid deprecation warning. 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