Sha256: 933a5ef5a71c2d121312ceb2af8977cd6a0985ab7ba3276fe77051e96ea4cd9e

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

$:.unshift File.dirname(__FILE__)

require 'common_templatelet_test'

$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')

module BuildMaster
class HrefTest < CommonTemplateletTest
  def setup
    super
    @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

  def test_should_populate_href_attribute_with_full_url
    expected_url = 'http://www.rubyforge.org'
    @template_element.attributes['url']=expected_url
    @href.process(@target_element, @template_element, source('index.html'))
    assert_equal(expected_url, @target_element.attributes['href'])
  end
  
  def test_should_populate_href_attribute_with_relative_path
    @template_element.attributes['url']='doc/doc.html'
    @href.process(@target_element, @template_element, source('download/index.html'))
    assert_equal('../doc/doc.html', @target_element.attributes['href'])
  end
  
  def test_should_support_image_tag_by_generating_src_attribute
    @template_element.attributes['url']='doc/doc.gif'
    @target_element = create_element('img')
    @href.process(@target_element, @template_element, source('download/download.html'))
    assert_equal('../doc/doc.gif', @target_element.attributes['src'])
  end
  
  def test_should_handle_external_links
    @template_element.attributes['url'] = 'http://www.google.com'
    @target_element = create_element('img')
    @href.process(@target_element, @template_element, source('download/download.html'))
    assert_equal('http://www.google.com', @target_element.attributes['src'])
  end
  
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BuildMaster-0.8.0 test/buildmaster/templatelets/tc_href.rb