require 'rake' require 'cucumber/rake/task' module Henry class Task # The Henry Task implementation for Cucumber class CucumberTask < Task # The temporary output file path for the RspecTask execution. OUT_PATH = 'cucumber.out' # The reports path template. REPORTS_DIR = '.henry/reports/${FORMAT}' # Executes the CucumberTask and returns its results. def execute begin Rake.application['cucumber'].invoke self.execution.code = 'OK' self.execution.message = 'OK' self.execution.output = File.open(OUT_PATH, 'r').read rescue Exception => e self.execution.code = 'ERROR' self.execution.message = 'ERROR' self.execution.output = File.open(OUT_PATH, 'r').read self.execution.backtrace = e.message end end # Configures the Task. # # @param [Hash] params the task params. def configure(params) 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 else t.cucumber_opts = "--out #{OUT_PATH}" t.fork = false end end self.export_params(params) end # Returns the custom cucumber_opts that user may have passed. # # @return [String] def custom_options "#{self.format_options} #{self.tags_options}" end # Returns the cucumber_opts related with formatting. # # @return [String] def format_options "--out #{OUT_PATH}" end # Returns the cucumber_opts related with tags to be run. # # @return [String] def tags_options return '' if self.data.options['tags'].nil? self.data.options['tags'].collect do |tag| "--tags #{tag}" end.join(' ') end end end end