Sha256: fe106540a5312df37d83627efc5a9f136e6e0f143ebc113320360d9d61cbd7c4

Contents?: true

Size: 1.85 KB

Versions: 19

Compression:

Stored size: 1.85 KB

Contents

require File.expand_path('../../helper', __FILE__)

class Reality::Generators::TestErbTemplate < Reality::TestCase

  class SimpleModel
    def name
      'SimpleModel'
    end

    def facet_enabled?(facet)
      true
    end
  end

  def test_erb_template
    template_set = Reality::Generators::TemplateSet.new(TestTemplateSetContainer, 'foo')

    output_filename_pattern = 'main/java/#{component.name}.java'
    template_filename = File.expand_path(File.dirname(__FILE__) + '/jpa/templates/mytemplate.java.erb')
    TestTemplateSetContainer.target_manager.target(:component)

    template1 = Reality::Generators::ErbTemplate.new(template_set, [], :component, template_filename, output_filename_pattern, [], {})

    assert_equal output_filename_pattern, template1.output_filename_pattern
    assert_equal output_filename_pattern, template1.output_path
    assert_equal template_set, template1.template_set
    assert_equal [], template1.facets
    assert_equal :component, template1.target
    assert_equal [], template1.helpers
    assert_equal template_filename, template1.template_key
    assert_equal nil, template1.guard
    assert_equal({}, template1.extra_data)
    assert_equal 'foo:mytemplate.java', template1.name

    target_basedir = "#{temp_dir}/generated/erb_template"
    target_filename = "#{target_basedir}/main/java/SimpleModel.java"
    other_filename = "#{target_basedir}/main/java/Other.java"
    unprocessed_files = %W(#{target_filename} #{other_filename})
    assert_equal false, File.exist?(target_filename)
    template1.generate(target_basedir, SimpleModel.new, unprocessed_files)
    assert_equal true, File.exist?(target_filename)
    assert_equal 1, unprocessed_files.size

    assert_equal <<JAVA, IO.read(target_filename)
/* DO NOT EDIT: File is auto-generated */

@javax.annotation.Generated( "reality-generators" )
public class SimpleModel
{
}
JAVA
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
reality-generators-1.23.0 test/generators/test_erb_template.rb
reality-generators-1.22.0 test/generators/test_erb_template.rb
reality-generators-1.21.0 test/generators/test_erb_template.rb
reality-generators-1.20.0 test/generators/test_erb_template.rb
reality-generators-1.19.0 test/generators/test_erb_template.rb
reality-generators-1.18.0 test/generators/test_erb_template.rb
reality-generators-1.17.0 test/generators/test_erb_template.rb
reality-generators-1.16.0 test/generators/test_erb_template.rb
reality-generators-1.15.0 test/generators/test_erb_template.rb
reality-generators-1.14.0 test/generators/test_erb_template.rb
reality-generators-1.13.0 test/generators/test_erb_template.rb
reality-generators-1.12.0 test/generators/test_erb_template.rb
reality-generators-1.11.0 test/generators/test_erb_template.rb
reality-generators-1.10.0 test/generators/test_erb_template.rb
reality-generators-1.9.0 test/generators/test_erb_template.rb
reality-generators-1.8.0 test/generators/test_erb_template.rb
reality-generators-1.7.0 test/generators/test_erb_template.rb
reality-generators-1.6.0 test/generators/test_erb_template.rb
reality-generators-1.5.0 test/generators/test_erb_template.rb