require 'rake' require 'rspec/core/rake_task' module Henry class Task # The Henry Task implementation for Rspec class RspecTask < Task # Makes available the spec rake task. RSpec::Core::RakeTask.new do |t| t.rspec_opts = '--out rspec.out --format documentation --color' end # Executes the CucumberTask and returns its results. # # @return [Hash] the CucumberTask results. def execute(params) begin File.open('rspec.out', 'w') { |f| } tail_pid = Process.spawn('tail -f rspec.out') Rake.application['spec'].invoke Process.kill(:SIGINT, tail_pid) { name: self.name, code: 'OK', message: 'OK', returnedData: { output: File.open('rspec.out', 'r').read } } rescue Exception => e { name: self.name, code: 'ERROR', message: 'ERROR', returnedData: { output: File.open('rspec.out', 'r').read, backtrace: e.message } } end end end end end