Sha256: d69345a26798c1b09805f0fee028f2caf9de0dd1d867b281d0a32818d79cc2ad

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

$:.unshift File.dirname(__FILE__)

require 'common_templatelet_test'

module BuildMaster
describe 'HrefTest' do
  include HelperMethods
  before 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, nil)
  end

  it '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 == expected_url
  end
  
  it '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 == '../doc/doc.html'
  end
  
  it '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 == '../doc/doc.gif'
  end
  
  it '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 == 'http://www.google.com'
  end

  it '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 == '../doc.html'
  end
  
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BuildMaster-1.1.9 test/buildmaster/site/templatelets/tc_href.rb