$:.unshift File.dirname(__FILE__) require 'common_templatelet_test' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') module BuildMaster context 'HrefTest' do include HelperMethods setup do setup_spec @template_element = create_element('href') @target_element = create_element('a') @href = Href.new(@site_spec) end def source(path) SourceContent.new(Pathname.new(path), nil) end specify 'should_populate_href_attribute_with_full_url' do expected_url = 'http://www.rubyforge.org' @template_element.attributes['url']=expected_url @href.process(@target_element, @template_element, source('index.html')) @target_element.attributes['href'].should_equal expected_url end specify 'should_populate_href_attribute_with_relative_path' do @template_element.attributes['url']='doc/doc.html' @href.process(@target_element, @template_element, source('download/index.html')) @target_element.attributes['href'].should_equal '../doc/doc.html' end specify 'should_support_image_tag_by_generating_src_attribute' do @template_element.attributes['url']='doc/doc.gif' @target_element = create_element('img') @href.process(@target_element, @template_element, source('download/download.html')) @target_element.attributes['src'].should_equal '../doc/doc.gif' end specify 'should_handle_external_links' do @template_element.attributes['url'] = 'http://www.google.com' @target_element = create_element('img') @href.process(@target_element, @template_element, source('download/download.html')) @target_element.attributes['src'].should_equal 'http://www.google.com' end specify 'should_handle_absolute_path' do @template_element.attributes['url'] = '/doc.html' @target_element = create_element('img') @href.process(@target_element, @template_element, source('download/download.html')) @target_element.attributes['src'].should_equal '../doc.html' end end end