Sha256: 62e48849fa0779f16a9d5730b3736d6d681f865fa057a3158d9ef9a8d2d263e7

Contents?: true

Size: 1.91 KB

Versions: 6

Compression:

Stored size: 1.91 KB

Contents

# Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require 'trenni/formatters'

module Trenni::Formatters::HTML::OptionSelectSpec
	class FormFormatter < Trenni::Formatters::Formatter
		include Trenni::Formatters::HTML::DefinitionListForm
		
		def select(options = {}, &block)
			element(Trenni::Formatters::HTML::OptionSelect, options, &block)
		end
	end
	
	describe Trenni::Formatters::HTML::OptionSelect do
		let(:formatter) {FormFormatter.new(:object => double(:bar => 10))}
		
		it "should format items" do
			_out = []
			
			formatter.select :field => :bar do |select|
				_out << select.item(:title => "A", :value => 0)
				_out << select.item(:title => "B", :value => 10)
			end
			
			expect(_out.join).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar\">\n\t\t<option value=\"0\">A</option><option value=\"10\" selected>B</option>\n\t</select>\n</dd>"
		end
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trenni-formatters-0.5.3 spec/trenni/formatters/html/option_select_spec.rb
trenni-formatters-0.5.2 spec/trenni/formatters/html/option_select_spec.rb
trenni-formatters-0.5.1 spec/trenni/formatters/html/option_select_spec.rb
trenni-formatters-0.5.0 spec/trenni/formatters/html/option_select_spec.rb
trenni-formatters-0.4.4 spec/trenni/formatters/html/option_select_spec.rb
trenni-formatters-0.4.3 spec/trenni/formatters/html/option_select_spec.rb