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'
- DEFAULT_OUTPUT_BASE_DIR =
Default base output directory
'.output'
- REPORTS_DIR =
The reports path template.
'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 collapse
-
#generated_reports ⇒ Object
Returns the value of attribute generated_reports.
-
#report_recipients ⇒ Object
Returns the value of attribute report_recipients.
Attributes inherited from Henry::Task
#data, #enabled, #name, #timeout
Instance Method Summary collapse
- #after_execute ⇒ Object
- #application_name ⇒ Object
-
#base_output_path ⇒ String
Returns output base path.
-
#configure(params, extended_context = {}) ⇒ Object
Configures the Task.
-
#custom_options(extended_options = {}) ⇒ String
Returns the custom cucumber_opts that user may have passed.
-
#default_options ⇒ String
Returns the default cucumber_opts.
- #execute ⇒ Object
-
#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, extended_options = {}) ⇒ Object
Interpolates and returns the report file name.
-
#report_file_path(format, file_name, extended_options = {}) ⇒ String
Returns the report file path for the given format and file name.
-
#report_options(extended_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(extended_options = {}) ⇒ String
Returns the cucumber_opts related with tags to be run.
Methods inherited from Henry::Task
#before_execute, create, #disable!, #disabled?, #enable!, #enabled?, #execution, #execution=, #export_config, #export_params, #initialize, #logger, #report
Constructor Details
This class inherits a constructor from Henry::Task
Instance Attribute Details
#generated_reports ⇒ Object
Returns the value of attribute generated_reports.
11 12 13 |
# File 'lib/henry/task/cucumber_task.rb', line 11 def generated_reports @generated_reports end |
#report_recipients ⇒ Object
Returns the value of attribute report_recipients.
11 12 13 |
# File 'lib/henry/task/cucumber_task.rb', line 11 def report_recipients @report_recipients end |
Instance Method Details
#after_execute ⇒ Object
46 47 48 |
# File 'lib/henry/task/cucumber_task.rb', line 46 def after_execute super end |
#application_name ⇒ Object
30 31 32 |
# File 'lib/henry/task/cucumber_task.rb', line 30 def application_name APPLICATION_NAME end |
#base_output_path ⇒ String
Returns output base path
53 54 55 |
# File 'lib/henry/task/cucumber_task.rb', line 53 def base_output_path @base_output_path ||= (self.data.system[:output_directory] ? "#{self.data.system[:output_directory]}/output" : DEFAULT_OUTPUT_BASE_PATH) end |
#configure(params, extended_context = {}) ⇒ Object
Configures the Task.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/henry/task/cucumber_task.rb', line 61 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.() end end super end |
#custom_options(extended_options = {}) ⇒ String
Returns the custom cucumber_opts that user may have passed.
81 82 83 |
# File 'lib/henry/task/cucumber_task.rb', line 81 def (={}) "#{self.} #{self.()} #{self.()} #{self.} #{self.}" end |
#default_options ⇒ String
Returns the default cucumber_opts.
100 101 102 |
# File 'lib/henry/task/cucumber_task.rb', line 100 def "--format pretty --format pretty --out #{OUT_PATH}" end |
#execute ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/henry/task/cucumber_task.rb', line 38 def execute super if self.execution.code == 'OK' self.execution.code = 'ERROR' if self.execution.output =~ /\d+ scenarios? \([^\(]*\d+ failed[^\(]*\)/ end end |
#format_options ⇒ String
Returns the cucumber_opts related with formatting.
107 108 109 |
# File 'lib/henry/task/cucumber_task.rb', line 107 def "--format #{self.data.['format'] || 'pretty'} --format #{self.data.['format'] || 'pretty'} --out #{OUT_PATH}" end |
#misc_options ⇒ String
Returns the miscellaneous cucumber_opts.
88 89 90 91 92 93 94 95 |
# File 'lib/henry/task/cucumber_task.rb', line 88 def = [] << '--expand' if self.data.['expand'] << "--require features #{self.data.['pattern']}" if self.data.['pattern'] << '--no-source' if self.data.['no-source'] return .join(' ') end |
#out_path ⇒ Object
34 35 36 |
# File 'lib/henry/task/cucumber_task.rb', line 34 def out_path OUT_PATH end |
#report_file_name(file_name, extended_options = {}) ⇒ Object
Interpolates and returns the report file name.
177 178 179 |
# File 'lib/henry/task/cucumber_task.rb', line 177 def report_file_name(file_name,={}) file_name.gsub(/\${[A-Z_]+}/, '${TASK_NAME}' => self.name, '${DATE}' => DateTime.now.strftime(TIME_FORMAT), '${TAGS}' => ((self.data.['tags']||[])+(['tags']||[])).join(' ')).gsub(' ', '_') end |
#report_file_path(format, file_name, extended_options = {}) ⇒ String
Returns the report file path for the given format and file name.
169 170 171 |
# File 'lib/henry/task/cucumber_task.rb', line 169 def report_file_path(format, file_name, ={}) "#{self.reports_dir(format)}/#{self.report_file_name(file_name,)}" end |
#report_options(extended_options = {}) ⇒ String
Returns the cucumber_opts related with report paaths and formats.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/henry/task/cucumber_task.rb', line 126 def (={}) self.generated_reports = [] self.report_recipients = [] return '' if self.data.reports.nil? self.data.reports.collect do || ['name'] ||= "${DATE}_${TASK_NAME}.#{['format']}" self.generated_reports << self.report_file_path(['format'], ['name'], ) self.report_recipients += (['recipients'] || []) 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.
185 186 187 |
# File 'lib/henry/task/cucumber_task.rb', line 185 def reports_dir(format) "#{self.base_output_path}/#{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.
160 161 162 |
# File 'lib/henry/task/cucumber_task.rb', line 160 def rerun? self.data.['rerun'] && self.data.['rerun'] >= 0 end |
#rerun_options ⇒ String
Returns the cucumber_opts related with the rerun usage.
147 148 149 150 151 152 153 154 155 |
# File 'lib/henry/task/cucumber_task.rb', line 147 def return '' return '' if self.data.['rerun'].nil? self.data.['rerun'] -= 1 "---format rerun --out tmp/rerun" end |
#tags_options(extended_options = {}) ⇒ String
Returns the cucumber_opts related with tags to be run.
115 116 117 118 119 120 121 |
# File 'lib/henry/task/cucumber_task.rb', line 115 def (={}) return '' if self.data.['tags'].nil? && ['tags'].nil? ((self.data.['tags']||[])+(['tags']||[])).collect do |tag| "--tags #{tag.gsub(/(,?~?)(\w+)/, '\1@\2')}" end.join(' ') end |