Render_template giving an odd error?

Hey all, I’m trying to migrate over to Rails3/RSpec2 and I cannot seem
to get the specing of render right. I know there was some changes in
RSpec2 that affect this, and I was hoping to get a bit of help.

I have this is in a before block in a view spec:

view.should render_template(“attachments/index”, :locals => {:obj =>
@obj})

When I run the spec, it bombs out with this error:

expecting <“attachments/index”> but rendering with <"">.
Expected block to return true value.

This doesn’t tell me much, and aside from the RSpec2 syntax updates
the spec hasn’t changed (and used to work in Rails2).

This is a huge blocker for my app migration. I have 150+ models and
use partials pretty often.

Help is appreciated!

On Tue, Oct 5, 2010 at 8:03 AM, Matt D. [email protected] wrote:

Hey all, I’m trying to migrate over to Rails3/RSpec2 and I cannot seem
to get the specing of render right. I know there was some changes in
RSpec2 that affect this, and I was hoping to get a bit of help.

I have this is in a before block in a view spec:

view.should render_template(“attachments/index”, :locals => {:obj =>
@obj})

In rspec-2 you need to specify templates after rendering:

it " … " do
render
view.should render_template(“…”)
end

When I run the spec, it bombs out with this error:

expecting <“attachments/index”> but rendering with <“”>.
Expected block to return true value.

This doesn’t tell me much, and aside from the RSpec2 syntax updates
the spec hasn’t changed (and used to work in Rails2).

In rspec-rails-1/rails-2, rspec monkey-patched the )(&)( out of
rails to be able to do things like mock partial calls, etc. This led
to a world of pain from release to release, so we’re not doing that
anymore. The bad news is that you need to set up all the necessary
data to render any partials rendered by your views. The good news is
you can still specify which templates get rendered, as described
above.

This is a huge blocker for my app migration. I have 150+ models and
use partials pretty often.

Help is appreciated!

HTH,
David