Sha256: 5a898b8ef807e8fd5aa015f13d9b04a58ac6d957e280b83f303a10224adff46e

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require File.join(File.dirname(__FILE__), "test_helper")

class TestClassGeneratorTest < Test::Unit::TestCase
  include SproutTestCase

  context "a new test class generator" do

    setup do
      @fixtures = File.join('sprout', 'test', 'fixtures')
      @temp = File.join(fixtures, 'tmp')
      FileUtils.mkdir_p @temp

      @generator = AsUnit4::TestClassGenerator.new
      @generator.path = @temp
      @generator.logger = StringIO.new
    end

    teardown do
      remove_file @temp
    end

    should "work with a simple class" do
      @generator.input = 'utils.MathUtilTest'
      @generator.execute

      assert_file File.join(@temp, 'test', 'utils', 'MathUtilTest.as') do |content|
        assert_matches /class MathUtilTest \{/, content
        assert_matches /private var .*:MathUtil;/, content
        assert_matches /new MathUtil\(\);/, content
      end
      assert_file File.join(@temp, 'test', 'AllTests.as') do |content|
        assert_matches /import utils.MathUtilTest;/, content
        assert_matches /public var utils_MathUtilTest:utils\.MathUtilTest;/, content
      end
    end

    should "work without test suffix in the request" do
      @generator.input = 'utils.MathUtil'
      @generator.execute
      assert_file File.join(@temp, 'test', 'utils', 'MathUtilTest.as') do |content|
        assert_matches /class MathUtilTest \{/, content
        assert_matches /private var instance:MathUtil/, content
      end
      assert_file File.join(@temp, 'test', 'AllTests.as') do |content|
        assert_matches /import utils.MathUtilTest/, content
        assert_matches /public var utils_MathUtilTest:utils\.MathUtilTest;/, content
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asunit4-4.2.3.pre sprout/test/unit/test_class_generator_test.rb
asunit4-4.2.2.pre sprout/test/unit/test_class_generator_test.rb