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

'.henry'
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, #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 ||= DEFAULT_OUTPUT_BASE_PATH
end

#base_output_path=(path) ⇒ Object

Sets the output base path.



40
41
42
# File 'lib/henry/task/minitest_task.rb', line 40

def base_output_path=(path)
  @base_output_path = path
end

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

Configures the Task.

Parameters:

  • params (Hash)

    the task params.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/henry/task/minitest_task.rb', line 47

def configure(params, extended_context={}, options={})
  self.base_output_path = options[:output_directory] if options[:output_directory]

  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