Sha256: 24f1b5de8fd8e6dc2f5c254762c05f63ded8883fd8916d390e5a454ef2dc5d53

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

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

require 'test/unit'
require 'nitro/builders/xhtml'

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

	def test_options
		x = XhtmlString.new
		options = ['Male', 'Female']
		x.select(:name => 'sex') do
			x.options(options, 1)
		end
		res = '<select name="sex"><option value="0">Male</option>' +
					'<option value="1" selected="1">Female</option></select>'
		assert_equal res, x

		x = XhtmlString.new
		options = ['Male', 'Female']
		x.select('-- Select sex --', :name => 'sex') do
			x.options(options, 1)
		end
		res = '<select name="sex"><option>-- Select sex --</option>' +
					'<option value="0">Male</option>' +
					'<option value="1" selected="1">Female</option></select>'
		assert_equal res, x

		x = XhtmlString.new
		options = {'Male' => 'm', 'Female' => 'f'}
		x.select(:name => 'sex') do
			x.options(options, 'm')
		end
		res = '<select name="sex"><option value="m" selected="1">Male</option>' +
					'<option value="f">Female</option></select>'
		assert_equal res, x
	end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.16.0 test/nitro/builders/tc_xhtml.rb
nitro-0.17.0 test/nitro/builders/tc_xhtml.rb