Sha256: 7579771e031ccbbde98d61ebac10fb9ab650df1fa749525f758fc710dfc0809a
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
$:.unshift File.dirname(__FILE__) require 'common_templatelet_test' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') require 'buildmaster/template_exception' require 'buildmaster/templatelets/attribute' module BuildMaster class AttributeTest < CommonTemplateletTest def test_should_set_attribute_based_on_evaluation templatelet = Attribute.new(AttributeForTest.new(self)) target = create_element('a') template_element = create_attribute_element('attr-name', 'expression') expected_pathname = Pathname.new('/path') @source_path = SourceContent.new(expected_pathname, nil) templatelet.process(target, template_element, @source_path) assert_equal('value', target.attributes['attr-name']) assert_equal(expected_pathname, @path_logged) end def test_should_check_for_expression_responder target = create_element('a') template_element = create_attribute_element('name', 'eval') source_path = SourceContent.new(Pathname.new('./'), create_element('name')) begin Attribute.new(self).process(target, template_element, source_path) fail('template exception should have been thrown') rescue TemplateException => e assert_equal(true, e.message.include?('eval')) end end def create_attribute_element(name, eval) element = create_element('attribute') element.attributes['name'] = name element.attributes['eval'] = eval return element end def expression_called_with(path) @path_logged = path end end class AttributeForTest def initialize(logger) @logger = logger end def expression(path) @logger.expression_called_with(path) return 'value' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
BuildMaster-0.8.0 | test/buildmaster/templatelets/tc_attribute.rb |
BuildMaster-0.8.1 | test/buildmaster/templatelets/tc_attribute.rb |