Sha256: 542fa164142ec89015743e7703d4dc9809e530381057a8d685fd8f78e5e7ef40

Contents?: true

Size: 1.69 KB

Versions: 33

Compression:

Stored size: 1.69 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'
      
      # Default base output directory
      DEFAULT_OUTPUT_BASE_DIR = '.output'

      # The reports path template.
      REPORTS_DIR = '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

      # Returns output base path
      #
      # @return [String] the base output path.
      def base_output_path
        @base_output_path ||= (self.data.system[:output_directory] ? "#{self.data.system[:output_directory]}/output" : DEFAULT_OUTPUT_BASE_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

33 entries across 33 versions & 1 rubygems

Version Path
henry-container-0.1.82 lib/henry/task/minitest_task.rb
henry-container-0.1.81 lib/henry/task/minitest_task.rb
henry-container-0.1.80 lib/henry/task/minitest_task.rb
henry-container-0.1.79 lib/henry/task/minitest_task.rb
henry-container-0.1.78 lib/henry/task/minitest_task.rb
henry-container-0.1.77 lib/henry/task/minitest_task.rb
henry-container-0.1.76 lib/henry/task/minitest_task.rb
henry-container-0.1.75 lib/henry/task/minitest_task.rb
henry-container-0.1.74 lib/henry/task/minitest_task.rb
henry-container-0.1.73 lib/henry/task/minitest_task.rb
henry-container-0.1.72 lib/henry/task/minitest_task.rb
henry-container-0.1.71 lib/henry/task/minitest_task.rb
henry-container-0.1.70 lib/henry/task/minitest_task.rb
henry-container-0.1.69 lib/henry/task/minitest_task.rb
henry-container-0.1.68 lib/henry/task/minitest_task.rb
henry-container-0.1.67 lib/henry/task/minitest_task.rb
henry-container-0.1.66 lib/henry/task/minitest_task.rb
henry-container-0.1.65 lib/henry/task/minitest_task.rb
henry-container-0.1.64 lib/henry/task/minitest_task.rb
henry-container-0.1.63 lib/henry/task/minitest_task.rb