Sha256: a5af6460eeff2bba0edc840d9a3dd7b6b0c66de045042e6c6b6a553148f2aaef

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

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

require 'test/unit'
require 'nitro/builders/xml'

class TC_BuildersXml < Test::Unit::TestCase # :nodoc: all

	def test_string
		x = N::XmlString.new

		x.start_tag('html').
			start_tag('title').text('hello').end_tag('title').
		end_tag('html')
		
		assert_equal '<html><title>hello</title></html>', x
	end
	
	def test_missing
		x = N::XmlString.new
		x.b('This is bold')
		assert_equal '<b>This is bold</b>', x

		x = N::XmlString.new
		x.a('Navel', :href => 'http://www.navel.gr', :target => '_blank')
		assert_equal '<a target="_blank" href="http://www.navel.gr">Navel</a>', x


		x = N::XmlString.new
		x.b { 
			x.i 'Hello', :class =>'new'
			x.p 'Paragraph'
		}
		assert_equal '<b><i class="new">Hello</i><p>Paragraph</p></b>', x
	end

	def test_xml_builder
		buffer = ''
		x = N::XmlBuilder.new(buffer)

		x.start_tag('html').
			start_tag('title').text('hello').end_tag('title').
		end_tag('html')
		
		assert_equal '<html><title>hello</title></html>', buffer 
	end
		
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.8.0 test/nitro/builders/tc_xml.rb