test/buildmaster/templatelets/tc_link.rb in BuildMaster-0.8.1 vs test/buildmaster/templatelets/tc_link.rb in BuildMaster-0.9.0
- old
+ new
@@ -8,12 +8,18 @@
require 'rexml/xpath'
require 'buildmaster/site_spec'
require 'buildmaster/source_content'
module BuildMaster
-class LinkTest < CommonTemplateletTest
- def test_should_generate_link_with_relative_path
+context 'LinkTest' do
+ include HelperMethods
+
+ setup do
+ setup_spec
+ end
+
+ specify 'should_generate_link_with_relative_path' do
target = create_element('div')
template_content = <<CONTENT
<?xml ?>
<root>
<link href="content/path.html">text</link>
@@ -23,48 +29,48 @@
template = REXML::XPath.first(template_document, '/root/link')
source = create_element('source')
link = Link.new(SiteSpec.new)
link.process(target, template, SourceContent.new(Pathname.new('doc/doc.html'), source))
actual = REXML::XPath.first(target, 'a')
- assert_equal('../content/path.html', actual.attributes['href'])
- assert_equal('text', actual.text)
+ actual.attributes['href'].should_equal '../content/path.html'
+ actual.text.should_equal 'text'
end
- def test_should_copy_all_attributes
+ specify 'should_copy_all_attributes' do
target = create_element('div')
template = create_element('link')
template.attributes['href'] = 'content/path.html'
template.attributes['attribute1'] = 'value1'
template.attributes['attribute2'] = 'value2'
source = create_element('source')
link = Link.new(SiteSpec.new)
link.process(target, template, SourceContent.new(Pathname.new('doc/doc.html'), source))
actual = REXML::XPath.first(target, 'a')
- assert_equal('value1', actual.attributes['attribute1'])
- assert_equal('value2', actual.attributes['attribute2'])
+ actual.attributes['attribute1'].should_equal 'value1'
+ actual.attributes['attribute2'].should_equal 'value2'
end
- def test_should_handle_absolute_path
+ specify 'should_handle_absolute_path' do
target = create_element('div')
template = create_element('link')
template.attributes['href'] = '/content/path.html'
source = create_element('source')
link = Link.new(SiteSpec.new)
link.process(target, template, SourceContent.new(Pathname.new('doc/iste/doc.html'), source))
actual = REXML::XPath.first(target, 'a')
- assert_equal('../../content/path.html', actual.attributes['href'])
+ actual.attributes['href'].should_equal '../../content/path.html'
end
- def test_should_generate_div_with_current_class_attribute_if_link_is_on_current_page
+ specify 'should_generate_div_with_current_class_attribute_if_link_is_on_current_page' do
target = create_element('div')
template = create_element('link')
template.attributes['href'] = '/content/path.html'
source = create_element('source')
link = Link.new(SiteSpec.new)
link.process(target, template, SourceContent.new(Pathname.new('content/path.html'), source))
actual = REXML::XPath.first(target, 'div')
- assert_equal(nil, actual.attributes['href'])
- assert_equal('current', actual.attributes['class'])
+ actual.attributes['href'].should_equal nil
+ actual.attributes['class'].should_equal 'current'
end
end
end
\ No newline at end of file