test/buildmaster/site/tc_template_builder.rb in BuildMaster-0.9.1 vs test/buildmaster/site/tc_template_builder.rb in BuildMaster-1.0.6

- old
+ new

@@ -1,50 +1,50 @@ -$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') +$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster') require 'spec' require 'rexml/xpath' -require 'buildmaster/site/template_builder' -require 'buildmaster/tree_to_object' +require 'site/template_builder' +require 'common/tree_to_object' require 'yaml' module BuildMaster context 'Template Builder' do specify 'should generate template document' do builder = TemplateBuilder.new document = builder.generate - REXML::XPath.first(document, '/html/head/title/*').name.should_equal 'include' + REXML::XPath.first(document, '/html/head/title/*').name.should == 'include' assert_css_path(document, 'buildmaster.css') end specify 'should update header with title and css' do builder = TemplateBuilder.new builder.title_header = 'Title Header - ' builder.css_path = 'mycss.css' document = builder.generate first_child = REXML::XPath.first(document, '/html/head/title').children[0] - first_child.class.should_equal REXML::Text - first_child.value.should_equal 'Title Header - ' + first_child.class.should == REXML::Text + first_child.value.should == 'Title Header - ' assert_css_path(document, 'mycss.css') end specify 'test_should_have_logo_defaults' do builder = TemplateBuilder.new - builder.logo.path.should_equal nil - builder.logo.link.should_equal 'index.html' + builder.logo.path.should == nil + builder.logo.link.should == 'index.html' end specify 'test_should_generate_logo_and_link' do builder = TemplateBuilder.new builder.logo.path = 'gif/logo.gif' builder.logo.link = 'main.html' document = builder.generate header = assert_first(document, '/html/body/div[@class="header"]') anchor_href = assert_first(header, 'a/template:href') - anchor_href.attributes['url'].should_equal 'main.html' + anchor_href.attributes['url'].should == 'main.html' img_href = assert_first(header, 'a/img/template:href') - img_href.attributes['url'].should_equal 'gif/logo.gif' + img_href.attributes['url'].should == 'gif/logo.gif' end specify 'test_should_build_left_menu' do builder = TemplateBuilder.new builder.left_bottom_logo.path='http://www.example.com/logo.gif' @@ -54,22 +54,22 @@ group.more='more.html' group = builder.menu_group('Documentation', 'doc/index.html') group.menu_item('Getting Started', 'doc/getting-started') document = builder.generate groups = REXML::XPath.match(document, '/html/body/div[@class="left"]/div[@class="MenuGroup"]') - groups.size.should_equal 2 + groups.size.should == 2 first_group = groups[0] header = assert_first(first_group, 'h1') - header.text.should_equal 'Software' + header.text.should == 'Software' items = REXML::XPath.match(first_group, 'ul/li') - items.size.should_equal 3 + items.size.should == 3 first_item = items[0] anchor = assert_first(first_item, 'template:link') - anchor.attributes['href'].should_equal 'download.html' - anchor.text.should_equal 'Download' + anchor.attributes['href'].should == 'download.html' + anchor.text.should == 'Download' more = items[2] - more.attributes['class'].should_equal 'More' + more.attributes['class'].should == 'More' end specify 'should_have_releases_info' do builder = TemplateBuilder.new releases = builder.releases @@ -77,18 +77,18 @@ releases.pre_release_version = '0.7' releases.snap_shot_version = 'n/a' releases.download_link = 'download.html' releases.versioning_link = 'versioning.html' document = builder.generate - REXML::XPath.first(document, '/html/body/template:when/div[@class="right"]/div/h1').text.should_equal 'Latest Versions' + REXML::XPath.first(document, '/html/body/template:when/div[@class="right"]/div/h1').text.should == 'Latest Versions' end specify 'should_have_no_release_info_if_not_assigned' do builder = TemplateBuilder.new builder.releases.download_link = nil document = builder.generate - REXML::XPath.match(document, '/html/body/template:when/div/*').size.should_equal 0 + REXML::XPath.match(document, '/html/body/template:when/div/*').size.should == 0 end specify 'should_read_from_yaml' do content = <<CONTENT title_header: BuilderMaster - @@ -114,19 +114,19 @@ - title: Site Building link: build-site.html more: doc/index.html CONTENT builder = TreeToObject.from_yaml(content, TemplateBuilder.new) - builder.title_header.should_equal 'BuilderMaster -' - builder.logo.path.should_equal 'logo.gif' - builder.logo.link.should_equal 'index.html' + builder.title_header.should == 'BuilderMaster -' + builder.logo.path.should == 'logo.gif' + builder.logo.link.should == 'index.html' end private def assert_css_path(document, expected) href = REXML::XPath.first(document, '/html/head/link/*') - href.name.should_equal 'href' - href.attributes['url'].should_equal expected + href.name.should == 'href' + href.attributes['url'].should == expected end def assert_first(xml_model, xpath) first = REXML::XPath.first(xml_model, xpath) first.should_not_equal nil