require "spec_helper" [NestedForm::Builder, NestedForm::SimpleBuilder, defined?(NestedForm::FormtasticBuilder) ? NestedForm::FormtasticBuilder : nil].compact.each do |builder| describe builder do describe "with no options" do before(:each) do @project = Project.new @template = ActionView::Base.new @template.output_buffer = "" @builder = builder.new(:item, @project, @template, {}, proc {}) end it "has an add link which behaves similar to a Rails link_to" do @builder.link_to_add("Add", :tasks).should == 'Add' @builder.link_to_add("Add", :tasks, :class => "foo", :href => "url").should == 'Add' @builder.link_to_add(:tasks) { "Add" }.should == 'Add' end it "has a remove link which behaves similar to a Rails link_to" do @builder.link_to_remove("Remove").should == 'Remove' @builder.link_to_remove("Remove", :class => "foo", :href => "url").should == 'Remove' @builder.link_to_remove { "Remove" }.should == 'Remove' end it "should wrap nested fields each in a div with class" do 2.times { @project.tasks.build } @builder.fields_for(:tasks) do "Task" end.should == '