Sha256: fb0666ece3c563f3428666a5c3a0adcf126f16f636ba731cf6105741dfd32827

Contents?: true

Size: 1.4 KB

Versions: 12

Compression:

Stored size: 1.4 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
    if passed?
      unless @temp_dir.nil?
        FileUtils.rm_rf @temp_dir unless ENV['NO_DELETE_DIR'] == 'true'
        @temp_dir = nil
      end
    else
      $stderr.puts "Test #{self.class.name}.#{name} Failed. Leaving working directory #{@temp_dir}"
    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

12 entries across 12 versions & 1 rubygems

Version Path
reality-generators-1.23.0 test/helper.rb
reality-generators-1.22.0 test/helper.rb
reality-generators-1.21.0 test/helper.rb
reality-generators-1.20.0 test/helper.rb
reality-generators-1.19.0 test/helper.rb
reality-generators-1.18.0 test/helper.rb
reality-generators-1.17.0 test/helper.rb
reality-generators-1.16.0 test/helper.rb
reality-generators-1.15.0 test/helper.rb
reality-generators-1.14.0 test/helper.rb
reality-generators-1.13.0 test/helper.rb
reality-generators-1.12.0 test/helper.rb