.*<\/div><\/div>$/
end
it "has an input of type: #{type}" do
@result.should match /
'help me!').should == ""
end
it 'adds help block' do
@builder.text_field(:name, :help_block => 'help me!').should == ""
end
it 'adds error message and class' do
@builder.text_field(:name, :error => 'This is an error!').should == ""
end
it 'adds success message and class' do
@builder.text_field(:name, :success => 'This checked out OK').should == ""
end
it 'adds warning message and class' do
@builder.text_field(:name, :warning => 'Take a look at this...').should == ""
end
it 'prepends passed text' do
@builder.text_field(:name, :prepend => '@').should == ""
end
it 'appends passed text' do
@builder.text_field(:name, :append => '@').should == ""
end
it 'prepends and appends passed text' do
@builder.text_field(:name, :append => '@', :prepend => '#').should == ""
end
it 'appends button with default values' do
@builder.text_field(:name, :append_button => { :label => 'button label' }).should == ""
end
it 'appends button and overrides class and type' do
@builder.text_field(:name, :append_button => { :label => 'Danger!', :class => 'btn btn-danger', :type => 'submit' }).should == ""
end
it 'appends button with custom attributes' do
@builder.text_field(:name, :append_button => { :label => 'button label', :data => { :custom_1 => 'value 1', :custom_2 => 'value 2' } }).should == ""
end
it 'appends button with an icon' do
@builder.text_field(:name, :append_button => { :label => 'button label', :icon => 'icon-plus icon-white' }).should == ""
end
end
context 'label option' do
%w(select email_field file_field number_field password_field search_field text_area text_field url_field).each do |method_name|
it "should not add a label when ''" do
@builder.send(method_name.to_sym, 'name', :label => '').should_not match /<\/label>/
end
it 'should not add a label when false' do
@builder.send(method_name.to_sym, 'name', :label => false).should_not match /<\/label>/
end
end
end
end # extras
describe 'form actions' do
context 'actions' do
it 'adds additional block content' do
@builder.actions do
@builder.submit
end.should match(/.*?<\/div>/)
end
end
context 'submit' do
it 'adds btn primary class if no class is defined' do
@builder.submit.should match /class=\"btn btn-primary\"/
end
it 'allows for custom classes' do
@builder.submit(:class => 'btn btn-large btn-success').should match /class=\"btn btn-large btn-success\"/
end
end
context 'button' do
it 'adds btn primary class if no class is defined' do
@builder.button.should match /class=\"btn btn-primary\"/
end
it 'allows for custom classes' do
@builder.button(:class => 'btn btn-large btn-success').should match /class=\"btn btn-large btn-success\"/
end
end
context 'cancel' do
it 'creates a link with cancel btn class if no class is defined' do
@builder.should_receive(:link_to).with(I18n.t('bootstrap_forms.buttons.cancel'), :back, :class => 'btn cancel').and_return("")
@builder.cancel
end
it 'creates a link with custom classes when defined' do
@builder.should_receive(:link_to).with(I18n.t('bootstrap_forms.buttons.cancel'), :back, :class => 'btn btn-large my-cancel').and_return("")
@builder.cancel(:class => 'btn btn-large my-cancel')
end
end
end # actions
end