lib/henry/task/cucumber_task.rb in henry-container-0.0.49 vs lib/henry/task/cucumber_task.rb in henry-container-0.0.50

- old
+ new

@@ -53,11 +53,11 @@ # Returns the custom cucumber_opts that user may have passed. # # @return [String] def custom_options - "#{self.format_options} #{self.tags_options}" + "#{self.format_options} #{self.tags_options} #{self.report_options}" end # Returns the cucumber_opts related with formatting. # # @return [String] @@ -72,9 +72,45 @@ return '' if self.data.options['tags'].nil? self.data.options['tags'].collect do |tag| "--tags @#{tag.split(',').join(',@')}" end.join(' ') + end + + # Returns the cucumber_opts related with report paaths and formats. + # + # @return [String] + def report_options + 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 report file path for the given format and file name. + # + # @param [String] format the rspec formatter name. + # @param [String] file_name the report file name template. + # @return [String] the report file path. + def report_file_path(format, file_name) + "#{self.reports_dir(format)}/#{self.report_file_name(file_name)}" + end + + # Interpolates and returns the report file name. + # + # @param [String] file_name the report file name. + # @returns [String] the report file name. + def report_file_name(file_name) + file_name.gsub(/\${[A-Z_]+}/, '${TASK_NAME}' => self.name, '${DATE}' => DateTime.now.to_s).gsub(' ', '_') + end + + # Interpolates and returns the reports directory for the given format. + # + # @param [String] format the formatter name. + # @return [Stiring] the reports directory. + def reports_dir(format) + REPORTS_DIR.gsub(/\${[A-Z_]+}/, '${FORMAT}' => format).gsub(' ', '_') end end end