Sha256: 75ef1ee83efdb75f3d0f6409f29c421dc15fc3ce7f6f36dcbc4994e35eb8ba6b

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

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

require 'test/unit'
require 'nitro/builder/xml'

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

	def test_string
		x = 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 = XmlString.new
		x.b('This is bold')
		assert_equal '<b>This is bold</b>', x

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


		x = 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

		x = XmlString.new
		x.hr
		assert_equal '<hr />', x

		x = XmlString.new
		x.hr(:style => 'height: 1px')
		assert_equal '<hr style="height: 1px" />', x
	end

	def test_xml_builder
		buffer = ''
		x = 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

4 entries across 4 versions & 1 rubygems

Version Path
nitro-0.18.0 test/nitro/builder/tc_xml.rb
nitro-0.18.1 test/nitro/builder/tc_xml.rb
nitro-0.19.0 test/nitro/builder/tc_xml.rb
nitro-0.20.0 test/nitro/builder/tc_xml.rb