Sha256: 5439e9b6ef9a08162fdb41606c98203e229a3db83056de62cebee1297efaea8b

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

require 'rake/testtask'

module Henry

  class Task

    # The Henry Task implementation for MiniTest
    class MiniTestTask < RakeTask

      # The temporary output file path for the MiniTest execution.
      OUT_PATH = 'minitest.out'

      # The reports path template.
      REPORTS_DIR = '.henry/reports/minitest'
      
      # The Minitest Rake Application name.
      #
      # @return [String] the rake application name.
      APPLICATION_NAME = 'minitest'
      
      def application_name
        APPLICATION_NAME
      end

      def out_path
        OUT_PATH
      end

      # Configures the Task.
      #
      # @param [Hash] params the task params.
      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

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
henry-container-0.1.36 lib/henry/task/minitest_task.rb
henry-container-0.1.34 lib/henry/task/minitest_task.rb
henry-container-0.1.33 lib/henry/task/minitest_task.rb
henry-container-0.1.31 lib/henry/task/minitest_task.rb
henry-container-0.1.30 lib/henry/task/minitest_task.rb
henry-container-0.1.29 lib/henry/task/minitest_task.rb
henry-container-0.1.28 lib/henry/task/minitest_task.rb
henry-container-0.1.27 lib/henry/task/minitest_task.rb