require 'spec_helper' describe 'GenericFormFor::Inputs::UrlInput' do include GenericFormForSpecHelper before do @model = MyModel.new @output_buffer = '' end it "should genearate wrapped input with label" do with_form_config do GenericFormFor::FormBuilder.input_wrapper do wrap_in :class => "controls" do label_html input_html error_html end end @model.errors.add :home_page, "My mistake" concat(generic_form_for(@model, :url => "/hello") do |builder| concat(builder.input(:home_page, :as => :url)) end) output_buffer.should have_selector("input[@id='my_model_home_page'][@type='url']") output_buffer.should have_selector("label[@for='my_model_home_page']", :content => "HomePage") output_buffer.should have_selector("span[@class='error']", :content => "My mistake") output_buffer.should have_selector("div", :class => "url-input controls") end end end