Class: Cucumber::Rake::Task

Inherits:
Object show all
Defined in:
lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb

Overview

Defines a task for running features.

Direct Known Subclasses

FeatureTask

Constant Summary collapse

LIB =
File.expand_path(File.dirname(__FILE__) + '/../..')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_name = "features", desc = "Run Features with Cucumber") {|_self| ... } ⇒ Task

Define a task

Yields:

  • (_self)

Yield Parameters:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 19

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?
  define_task
end

Instance Attribute Details

#cucumber_optsObject

Returns the value of attribute cucumber_opts.



14
15
16
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 14

def cucumber_opts
  @cucumber_opts
end

#feature_listObject

Returns the value of attribute feature_list.



12
13
14
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 12

def feature_list
  @feature_list
end

#feature_patternObject

Returns the value of attribute feature_pattern.



13
14
15
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 13

def feature_pattern
  @feature_pattern
end

#libsObject

Returns the value of attribute libs.



9
10
11
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 9

def libs
  @libs
end

#rcovObject

Returns the value of attribute rcov.



15
16
17
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 15

def rcov
  @rcov
end

#rcov_optsObject

Returns the value of attribute rcov_opts.



16
17
18
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 16

def rcov_opts
  @rcov_opts
end

#step_listObject

Returns the value of attribute step_list.



10
11
12
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 10

def step_list
  @step_list
end

#step_patternObject

Returns the value of attribute step_pattern.



11
12
13
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 11

def step_pattern
  @step_pattern
end

Instance Method Details

#arguments_for_ruby_execution(task_args = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 38

def arguments_for_ruby_execution(task_args = nil)
  lib_args     = ['"%s"' % ([LIB] + libs).join(File::PATH_SEPARATOR)]
  cucumber_bin = ['"%s"' % Cucumber::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_taskObject



31
32
33
34
35
36
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 31

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:



58
59
60
61
62
63
64
65
66
67
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 58

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:



69
70
71
72
73
74
75
76
77
78
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/rake/task.rb', line 69

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