shared_examples 'a bootstrap form' do describe 'with no options' do describe 'error_messages' do it 'returns empty string without errors' do @builder.error_messages.should == '' end end describe 'text_area' do before(:each) do @result = @builder.text_area 'name' end it 'has textarea input' do @result.should match /textarea/ end end describe 'uneditable_input' do it 'generates wrapped input' do @builder.uneditable_input('name').should == "
" end it 'allows for an id' do @builder.uneditable_input('name', :id => 'myid').should match /
" end it 'allows custom label' do @builder.check_box('name', :label => 'custom label').should match /custom label<\/label>/ end it 'allows no label with :label => false ' do @builder.check_box('name', :label => false).should_not match /<\/label>/ end it 'allows no label with :label => '' ' do @builder.check_box('name', :label => '').should_not match /<\/label>/ end end describe 'radio_buttons' do before do if RUBY_VERSION < '1.9' @options = ActiveSupport::OrderedHash.new @options['One'] = '1' @options['Two'] = '2' else @options = {'One' => '1', 'Two' => '2'} end end it 'doesn\'t use field_options from previously generated field' do @builder.text_field :name, :label => 'Heading', :help_inline => 'Inline help', :help_block => 'Block help' @builder.radio_buttons(:name, @options).should == "
" end it 'sets field_options' do @builder.radio_buttons(:name, {'One' => '1', 'Two' => '2'}) @builder.instance_variable_get('@field_options').should == {:error => nil} end it 'generates wrapped input' do @builder.radio_buttons(:name, @options).should == "
" end it 'allows custom label' do @builder.radio_buttons(:name, @options, {:label => 'custom label'}).should match /custom label<\/label>/ end it 'allows no label' do @builder.radio_buttons(:name, @options, {:label => false}).should == "
" end end (%w{email file number password range search text url }.map{|field| ["#{field}_field",field]} + [['telephone_field', 'tel'], ['phone_field', 'tel']]).each do |field, type| describe "#{field}" do context 'result' do before(:each) do @result = @builder.send(field, 'name') end it 'is wrapped' do @result.should match /^