Calls with block in views

Hi!

I have a view:

<% restrict_to ‘admin’ do %>

<%= render :partial => 'detail' %>
<% end %>

What’s the best way to spec view in this case - I just want to yield
block in restrict_to call.

Thanks in advance,
Yury

On Mon, Aug 11, 2008 at 2:05 AM, Yury K. [email protected]
wrote:

What’s the best way to spec view in this case - I just want to yield block
in restrict_to call.

Here’s one way:

it “should render detail for admin” do
template.should_receive(:restrict_to).with(‘admin’).and_yield
template.expect_render(:partial => ‘detail’)
render ‘path/to/view’
end

it “should not render detail for non-admin” do
template.should_receive(:restrict_to).with(‘admin’)
template.expect_render(:partial => ‘detail’).never
render ‘path/to/view’
end

Cheers,
David