Sha256: 90e4b8561f49de2e2ad05b9484df2ea7299164db0c2f59244c4b89bd9677dfcf

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require 'spec/helper'

describe "Nagoro::Pipe::Element" do
  behaves_like 'xpath'

  def compile(obj)
    Nagoro::Template[Nagoro::Pipe::Element].compile(obj).compiled
  end

  Nagoro.element('Page') do |content, attrs|
    "(Page: #{content.dump})"
  end

  Nagoro.element('SideBar') do |content, attrs|
    "(SideBar: #{content.dump})"
  end

  Nagoro.file_element('Html', 'example/element/Html.nage')

  it 'should compile single element' do
    compile('<Page />').
      should == '(Page: "")'
  end

  it 'should compile two elements' do
    compile('<Page /><Page />').
      should == '(Page: "")(Page: "")'
  end

  it 'should compile nested elements' do
    compile('<Page><Page /></Page>').
      should == '(Page: "(Page: \\"\\")")'
  end

  it 'should compile different nested elements' do
    compile('<Page><SideBar /></Page>').
      should == '(Page: "(SideBar: \\"\\")")'
  end

  it 'should render file-elements' do
    doc = compile(File.read('example/hello.nag'))
    doc.should.not.be.empty
    xpath(doc, '//title').first.text.should == 'Hello, World!'
    xpath(doc, '//h1').first.text.should == 'Hello, World!'
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
manveru-nagoro-2009.01.29 spec/nagoro/pipe/element.rb
manveru-nagoro-2009.03.21 spec/nagoro/pipe/element.rb
manveru-nagoro-2009.03.28 spec/nagoro/pipe/element.rb
manveru-nagoro-2009.05 spec/nagoro/pipe/element.rb
nagoro-2009.05 spec/nagoro/pipe/element.rb