require 'spec_helper' describe 'BootstrapForms::FormBuilder' do context 'given a setup builder' do before(:each) do @project = Project.new @template = ActionView::Base.new @template.output_buffer ='' @builder = BootstrapForms::FormBuilder.new(:item, @project, @template, {}, proc {}) end context 'with no options' do it_behaves_like 'a bootstrap form' end context 'with the :namespace option' do before(:each) do @builder.options[:namespace] = 'foo' end it 'prefixs HTML ids correctly' do @builder.text_field('name').should match /<(input) .*id="foo_item_name"/ end end context 'with the :index option' do before(:each) do @builder.options[:index] = 69 end it 'uses the correct :index' do @builder.text_field('name').should match / 'foo' } end it 'does not add the class to the elements' do @builder.text_field('name').should_not match /.*<\/div>$/ end it 'have a list with errors' do @result.should match /