diff --git a/spec/cocoon_spec.rb b/spec/cocoon_spec.rb index dc36ec2..bf2a2e1 100644 --- a/spec/cocoon_spec.rb +++ b/spec/cocoon_spec.rb @@ -81,14 +81,21 @@ describe Cocoon do end end - context "with extra render-options to pass locals to the partial" do - it "uses the correct plural" do + context "passing locals to the partial" do + it "when given: passes the locals to the partials" do @tester.unstub(:render_association) @form_obj.should_receive(:fields_for) { | association, new_object, options_hash, &block| block.call } @tester.should_receive(:render).with("person_fields", {:f=>nil, :dynamic=>true, :alfred=>"Judoka"}).and_return ("partiallll") result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline', :locals => {:alfred => 'Judoka'}}) result.to_s.should == 'add something' end + it "if no locals are given it still works" do + @tester.unstub(:render_association) + @form_obj.should_receive(:fields_for) { | association, new_object, options_hash, &block| block.call } + @tester.should_receive(:render).with("person_fields", {:f=>nil, :dynamic=>true}).and_return ("partiallll") + result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline'}) + result.to_s.should == 'add something' + end end