Class: Henry::Task::MiniTestTask

Inherits:
RakeTask show all
Defined in:
lib/henry/task/minitest_task.rb

Overview

The Henry Task implementation for MiniTest

Constant Summary collapse

OUT_PATH =

The temporary output file path for the MiniTest execution.

'minitest.out'
DEFAULT_OUTPUT_BASE_DIR =

Default base output directory

'.output'
REPORTS_DIR =

The reports path template.

'reports/minitest'
APPLICATION_NAME =

The Minitest Rake Application name.

Returns:

  • (String)

    the rake application name.

'minitest'

Instance Attribute Summary

Attributes inherited from Henry::Task

#data, #enabled, #name, #timeout

Instance Method Summary collapse

Methods inherited from RakeTask

#execute

Methods inherited from Henry::Task

#after_execute, #before_execute, create, #disable!, #disabled?, #enable!, #enabled?, #execute, #execution, #execution=, #export_config, #export_params, #initialize, #logger, #report

Constructor Details

This class inherits a constructor from Henry::Task

Instance Method Details

#application_nameObject



24
25
26
# File 'lib/henry/task/minitest_task.rb', line 24

def application_name
  APPLICATION_NAME
end

#base_output_pathString

Returns output base path

Returns:

  • (String)

    the base output path.



35
36
37
# File 'lib/henry/task/minitest_task.rb', line 35

def base_output_path
  @base_output_path ||= (self.data.system[:output_directory] ? "#{self.data.system[:output_directory]}/output" : DEFAULT_OUTPUT_BASE_PATH)
end

#configure(params, extended_context = {}) ⇒ Object

Configures the Task.

Parameters:

  • params (Hash)

    the task params.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/henry/task/minitest_task.rb', line 42

def configure(params, extended_context={})
  File.open(OUT_PATH, 'w') { |f| }

  pattern = params['pattern'] || './spec{,/*/**}/*_spec.rb'
  format  = params['format']  || 'DefaultReporter'

  File.open("preconfig.rb", 'w') do |f|
    f.write <<CODE
$stdout = File.open('#{OUT_PATH}', 'w')
require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/reporters'
MiniTest::Reporters.use! MiniTest::Reporters::#{format}.new
CODE
  end

  # Makes available the spec rake task.
  Rake::TestTask.new('minitest') do |t|
    t.pattern = pattern
    t.ruby_opts << "-r ./preconfig"
  end

  super
end

#out_pathObject



28
29
30
# File 'lib/henry/task/minitest_task.rb', line 28

def out_path
  OUT_PATH
end