Sha256: 817cae93a2782802494de12e1972f2a7edad2cde693f1e1a010d32bef2aa81c7
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
$:.unshift File.dirname(__FILE__) require 'common_templatelet_test' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') require 'rexml/document' require 'rexml/xpath' require 'buildmaster/site_spec' require 'buildmaster/templatelets' module BuildMaster context 'WhenTest' do include HelperMethods setup do setup_spec end specify 'should_process_child_when_evaluated_true' do target = create_element('target') template_content = <<CONTENT <when test='expression_for_true'> <h1>Header</h1> </when> CONTENT template_document = REXML::Document.new(template_content) template = REXML::XPath.first(template_document, '/when') when_processor = When.new(self, self) when_processor.process(target, template, self) actual = REXML::XPath.first(target, 'h1') actual.text.should_equal 'Header' end specify 'should_not_process_child_when_evaluated_false' do target = create_element('target') template_content = <<CONTENT <when test='expression_for_false'> <h1>Header</h1> </when> CONTENT template_document = REXML::Document.new(template_content) template = REXML::XPath.first(template_document, '/when') when_processor = When.new(self, self) when_processor.process(target, template, self) target.size.should_equal 0 end def path return Pathname.new('index.html') end def expression_for_true(path) return 'word two' =~ /word/ end def expression_for_false(path) return 'one word two' =~ /nomatch/ end def load_templatelets return Hash.new end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
BuildMaster-0.9.0 | test/buildmaster/templatelets/tc_when.rb |
BuildMaster-0.9.1 | test/buildmaster/templatelets/tc_when.rb |