Sha256: 78b7d8013184cd475bff32c56914bf90607ed7a82afd274df4a6cc63b16e5e7b

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

$:.unshift File.expand_path('../../lib', __FILE__)

require 'minitest/autorun'
require 'test/unit/assertions'
require 'reality/generators'

class Reality::TestCase < Minitest::Test
  include Test::Unit::Assertions
  include Reality::Logging::Assertions

  module TestTemplateSetContainer
    class << self
      include Reality::Generators::TemplateSetContainer

      def derive_default_helpers(options)
        helpers
      end

      attr_writer :helpers

      def helpers
        @helpers ||= []
      end

      def reset
        helpers.clear
        template_set_map.clear
        target_manager.reset_targets
      end
    end
  end

  def setup
    TestTemplateSetContainer.reset
    @temp_dir = nil
  end

  def teardown
    unless @temp_dir.nil?
      FileUtils.rm_rf @temp_dir unless ENV['NO_DELETE_DIR'] == 'true'
      @temp_dir = nil
    end
  end

  def temp_dir
    if @temp_dir.nil?
      base_temp_dir = ENV['TEST_TMP_DIR'] || File.expand_path("#{File.dirname(__FILE__)}/../tmp")
      @temp_dir = "#{base_temp_dir}/tests/generators-#{Time.now.to_i}"
      FileUtils.mkdir_p @temp_dir
    end
    @temp_dir
  end

  def assert_generator_error(expected_message, &block)
    assert_logging_error(Reality::Generators, expected_message) do
      yield block
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reality-generators-1.11.0 test/helper.rb
reality-generators-1.10.0 test/helper.rb
reality-generators-1.9.0 test/helper.rb
reality-generators-1.8.0 test/helper.rb
reality-generators-1.7.0 test/helper.rb
reality-generators-1.6.0 test/helper.rb
reality-generators-1.5.0 test/helper.rb