[rspec-devel] [ rspec-Patches-6989 ] partials with locals
noreply at rubyforge.org
noreply at rubyforge.org
Sat Dec 2 20:41:53 EST 2006
Patches item #6989, was opened at 2006-11-30 16:10
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=6989&group_id=797
Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Micah Martin (slagyr)
Assigned to: Nobody (None)
Summary: partials with locals
Initial Comment:
Here's a potential fix for the view specs. The problem was tests like this:
specify "blah" do
widget = mock("widget")
render "/path/to/_partial", :locals => {:widget => widget}
end
The view ViewEvalContext seems to expect all renders to be full templates. Normally it's not a problem but in this case I'm using the :locals options which is not applied to :template rendering.
So I tried this:
render :partial => "/path/to/partial", :locals => {:widget => widget}
But that failed because ViewEvalContext is expecting :templates. I was able to get it to work by modifying ViewEvalContext a tiny bit:
Original:
@controller.add_helper_for(options[:template])
Modified:
@controller.add_helper_for(options[:template]) if options[:template]
@controller.add_helper_for(options[:partial]) if options[:partial]
To complete a spec, the partial template might look like this:
<%= widget.to_s %>
Any chance this could be added to trunk?
----------------------------------------------------------------------
Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2006-12-02 11:54
Message:
Hi Micah,
Could you modify the RSpec demo app and other files and create a patch file for us? svn patch > patch_for_partials_with_locals.diff
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=6989&group_id=797
More information about the rspec-devel
mailing list