lib/henry/task/cucumber_task.rb in henry-container-0.0.44 vs lib/henry/task/cucumber_task.rb in henry-container-0.0.45

- old
+ new

@@ -6,40 +6,73 @@ 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. - # - # @return [Hash] the CucumberTask results. def execute begin Rake.application['cucumber'].invoke self.execution.code = 'OK' self.execution.message = 'OK' - self.execution.output = File.open('cucumber.out', 'r').read + 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('cucumber.out', 'r').read + 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('cucumber.out', 'w') { |f| } + File.open(OUT_PATH, 'w') { |f| } # Makes available the cucumber rake task. Cucumber::Rake::Task.new do |t| - t.cucumber_opts = %w{--out cucumber.out} - t.fork = false + if self.data.options + t.rspec_opts = self.custom_option + 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