Class: Henry::Task::CucumberTask
- Inherits:
-
RakeTask
- Object
- Henry::Task
- RakeTask
- Henry::Task::CucumberTask
- Defined in:
- lib/henry/task/cucumber_task.rb
Overview
The Henry Task implementation for Cucumber
Constant Summary collapse
- OUT_PATH =
The temporary output file path for the RspecTask execution.
'cucumber.out'
- REPORTS_DIR =
The reports path template.
'.henry/reports/${FORMAT}'
- TIME_FORMAT =
Default time format to be used in the reports filepath.
'%Y-%m-%dT%H%M%S'
- APPLICATION_NAME =
The Cucumber Rake Application name.
'cucumber'
Instance Attribute Summary
Attributes inherited from Henry::Task
Instance Method Summary collapse
- #application_name ⇒ Object
-
#configure(params, extended_context = {}) ⇒ Object
Configures the Task.
-
#custom_options ⇒ String
Returns the custom cucumber_opts that user may have passed.
-
#default_options ⇒ String
Returns the default cucumber_opts.
-
#format_options ⇒ String
Returns the cucumber_opts related with formatting.
-
#misc_options ⇒ String
Returns the miscellaneous cucumber_opts.
- #out_path ⇒ Object
-
#report_file_name(file_name) ⇒ Object
Interpolates and returns the report file name.
-
#report_file_path(format, file_name) ⇒ String
Returns the report file path for the given format and file name.
-
#report_options ⇒ String
Returns the cucumber_opts related with report paaths and formats.
-
#reports_dir(format) ⇒ Stiring
Interpolates and returns the reports directory for the given format.
-
#rerun? ⇒ True, False
Returns true whenever rerun is set and the reties counter is still positive.
-
#rerun_options ⇒ String
Returns the cucumber_opts related with the rerun usage.
-
#tags_options ⇒ String
Returns the cucumber_opts related with tags to be run.
Methods inherited from RakeTask
Methods inherited from Henry::Task
#after_execute, #before_execute, create, #disable!, #disabled?, #enable!, #enabled?, #execute, #execution, #export_params, #initialize, #logger, #report
Constructor Details
This class inherits a constructor from Henry::Task
Instance Method Details
#application_name ⇒ Object
25 26 27 |
# File 'lib/henry/task/cucumber_task.rb', line 25 def application_name APPLICATION_NAME end |
#configure(params, extended_context = {}) ⇒ Object
Configures the Task.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/henry/task/cucumber_task.rb', line 37 def configure(params, extended_context={}) File.open(OUT_PATH, 'w') { |f| } # Makes available the cucumber rake task. Rake.application.clear Cucumber::Rake::Task.new do |t| if self.data. t.cucumber_opts = "#{self.} #{extended_context['options']}" else t.cucumber_opts = "#{self.} #{extended_context['options']}" end end self.export_params(params) end |
#custom_options ⇒ String
Returns the custom cucumber_opts that user may have passed.
56 57 58 |
# File 'lib/henry/task/cucumber_task.rb', line 56 def "#{self.} #{self.} #{self.} #{self.} #{self.}" end |
#default_options ⇒ String
Returns the default cucumber_opts.
70 71 72 |
# File 'lib/henry/task/cucumber_task.rb', line 70 def "--format pretty --format pretty --out #{OUT_PATH}" end |
#format_options ⇒ String
Returns the cucumber_opts related with formatting.
77 78 79 |
# File 'lib/henry/task/cucumber_task.rb', line 77 def "--format #{self.data.['format'] || 'pretty'} --format #{self.data.['format'] || 'pretty'} --out #{OUT_PATH}" end |
#misc_options ⇒ String
Returns the miscellaneous cucumber_opts.
63 64 65 |
# File 'lib/henry/task/cucumber_task.rb', line 63 def "#{self.data.['expand'] ? '--expand' : ''} #{self.data.['pattern'] ? "--require features #{self.data.['pattern']}" : ''}" end |
#out_path ⇒ Object
29 30 31 |
# File 'lib/henry/task/cucumber_task.rb', line 29 def out_path OUT_PATH end |
#report_file_name(file_name) ⇒ Object
Interpolates and returns the report file name.
139 140 141 |
# File 'lib/henry/task/cucumber_task.rb', line 139 def report_file_name(file_name) file_name.gsub(/\${[A-Z_]+}/, '${TASK_NAME}' => self.name, '${DATE}' => DateTime.now.strftime(TIME_FORMAT)).gsub(' ', '_') end |
#report_file_path(format, file_name) ⇒ String
Returns the report file path for the given format and file name.
131 132 133 |
# File 'lib/henry/task/cucumber_task.rb', line 131 def report_file_path(format, file_name) "#{self.reports_dir(format)}/#{self.report_file_name(file_name)}" end |
#report_options ⇒ String
Returns the cucumber_opts related with report paaths and formats.
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/henry/task/cucumber_task.rb', line 95 def return '' if self.data.reports.nil? self.data.reports.collect do || ['name'] ||= "${DATE}_${TASK_NAME}.#{['format']}" FileUtils.mkdir_p(self.reports_dir(['format'])) "--format #{['format']} --out #{self.report_file_path(['format'], ['name'])}" end.join(' ') end |
#reports_dir(format) ⇒ Stiring
Interpolates and returns the reports directory for the given format.
147 148 149 |
# File 'lib/henry/task/cucumber_task.rb', line 147 def reports_dir(format) REPORTS_DIR.gsub(/\${[A-Z_]+}/, '${FORMAT}' => format).gsub(' ', '_') end |
#rerun? ⇒ True, False
Returns true whenever rerun is set and the reties counter is still positive.
122 123 124 |
# File 'lib/henry/task/cucumber_task.rb', line 122 def rerun? self.data.['rerun'] && self.data.['rerun'] >= 0 end |
#rerun_options ⇒ String
Returns the cucumber_opts related with the rerun usage.
109 110 111 112 113 114 115 116 117 |
# File 'lib/henry/task/cucumber_task.rb', line 109 def return '' return '' if self.data.['rerun'].nil? self.data.['rerun'] -= 1 "---format rerun --out tmp/rerun" end |
#tags_options ⇒ String
Returns the cucumber_opts related with tags to be run.
84 85 86 87 88 89 90 |
# File 'lib/henry/task/cucumber_task.rb', line 84 def return '' if self.data.['tags'].nil? self.data.['tags'].collect do |tag| "--tags #{tag.gsub(/(,?~?)(\w+)/, '\1@\2')}" end.join(' ') end |