lib/henry/task/cucumber_task.rb in henry-container-0.0.53 vs lib/henry/task/cucumber_task.rb in henry-container-0.0.54
- old
+ new
@@ -22,10 +22,12 @@
self.execution.code = 'OK'
self.execution.message = 'OK'
self.execution.output = File.open(OUT_PATH, 'r').read
self.execution.log = self.logger.log_as_hash
rescue Exception => e
+# retry if self.rerun?
+
self.execution.code = 'ERROR'
self.execution.message = 'ERROR'
self.execution.output = File.open(OUT_PATH, 'r').read
self.execution.backtrace = e.message
self.execution.log = self.logger.log_as_hash
@@ -33,19 +35,20 @@
end
# Configures the Task.
#
# @param [Hash] params the task params.
- def configure(params)
+ # @param [Hash] extended_context task extended context.
+ def configure(params, extended_context)
File.open(OUT_PATH, 'w') { |f| }
# Makes available the cucumber rake task.
Cucumber::Rake::Task.new do |t|
if self.data.options
- t.cucumber_opts = self.custom_options
+ t.cucumber_opts = "#{self.custom_options} #{extended_context['options']}"
else
- t.cucumber_opts = self.default_options
+ t.cucumber_opts = "#{self.default_options} #{extended_context['options']}"
t.fork = false
end
end
self.export_params(params)
@@ -53,11 +56,11 @@
# Returns the custom cucumber_opts that user may have passed.
#
# @return [String]
def custom_options
- "#{self.format_options} #{self.tags_options} #{self.report_options} #{self.misc_options}"
+ "#{self.format_options} #{self.tags_options} #{self.report_options} #{self.rerun_options} #{self.misc_options}"
end
# Returns the miscellaneous cucumber_opts.
#
# @return [String]
@@ -97,9 +100,29 @@
return '' if self.data.reports.nil?
self.data.reports.collect do |report_options|
"--format #{report_options['format']} --out #{self.report_file_path(report_options['format'], report_options['name'])}"
end.join(' ')
+ end
+
+ # Returns the cucumber_opts related with the rerun usage.
+ #
+ # @return [String]
+ def rerun_options
+ return ''
+
+ return '' if self.data.options['rerun'].nil?
+
+ self.data.options['rerun'] -= 1
+
+ "---format rerun --out tmp/rerun"
+ end
+
+ # Returns true whenever rerun is set and the reties counter is still positive.
+ #
+ # @return [True,False]
+ def rerun?
+ self.data.options['rerun'] && self.data.options['rerun'] >= 0
end
# Returns the report file path for the given format and file name.
#
# @param [String] format the rspec formatter name.