class Cucumber::Rake::Task
See the attributes for additional configuration possibilities.
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 cucumber_opts=(opts) # :nodoc:
def cucumber_opts=(opts) # :nodoc: unless opts.instance_of? String @cucumber_opts = opts return end @cucumber_opts = opts.split(' ') return if @cucumber_opts.length <= 1 $stderr.puts 'WARNING: consider using an array rather than a space-delimited string with cucumber_opts to avoid undesired behavior.' end
def cucumber_opts_with_profile # :nodoc:
def cucumber_opts_with_profile # :nodoc: Array(cucumber_opts).concat(Array(@profile).flat_map { |p| ['--profile', p] }) end
def define_task # :nodoc:
def define_task # :nodoc: desc @desc task @task_name do runner.run end end
def feature_files # :nodoc:
def feature_files # :nodoc: make_command_line_safe(FileList[ENV['FEATURE'] || []]) end
def initialize(task_name = 'cucumber', desc = 'Run Cucumber features')
def initialize(task_name = 'cucumber', desc = 'Run Cucumber features') @task_name = task_name @desc = desc @fork = true @libs = ['lib'] @rcov_opts = %w[--rails --exclude osx\/objc,gems\/] yield self if block_given? @binary = binary.nil? ? Cucumber::BINARY : File.expand_path(binary) define_task end
def make_command_line_safe(list)
def make_command_line_safe(list) list.map { |string| string.gsub(' ', '\ ') } end
def runner(_task_args = nil) # :nodoc:
def runner(_task_args = nil) # :nodoc: cucumber_opts = [ENV['CUCUMBER_OPTS']&.split(/\s+/) || cucumber_opts_with_profile] return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if fork InProcessCucumberRunner.new(libs, cucumber_opts, feature_files) end