[rspec-users] Specifying custom rails FormBuilders

Jay Levitt lists-rspec at shopwatch.org
Mon Aug 6 12:20:31 EDT 2007

I want to write a spec for a custom form builder, but I'm not really 
sure where it should live or how to include the right rspec_on_rails 
contexts.  Ideally, I should be able to write a spec like:

describe LabelledBuilder do
  it "should let me create a text field" do
    object = mock(object)
    object.stub!(:attribute).and_return("Test String")
    render :inline =>
      "<% form_for(@object, :builder => LabelledBuilder) do |f| -%>
        <%= f.text_field :attribute %>
       <% end %>"
    response.should have_tag("label")

but I'm not having much luck.  Can anyone give me an idea where to start?


More information about the rspec-users mailing list