Hi guys,<br><br>I am a Rspec newbie and am having problems creating a spec for a RoR helper method. <br><br>I
have in fact already implemented the helper method and am trying to
create retrospective specs. I know its the wrong way to do it but I am
still learning Rspec.
<br><br>In my view I have a call to a helper method.<br><br><% body_class "users" %><br><br>which sets a CSS class declaration in the content_for block which is then used in the <body> tag in application.html.erb
layout.<br><br> def body_class(class_name)<br> content_for(:body_class) { " class=\"#{class_name}\"" }<br> end<br><br><br>I was trying the following in my view spec:<br><br>template.should_receive
(:body_class).with("users")<div id="mb_0">.and_return(' class="users"')<br>render "/admin/users/index.html.erb", :layout => "application"<br>response.should have_tag('
body.users')
<br><br>I get a:<br><br>Expected at least 1 element matching "body.users", found 0.<br><false> is not true.<br><br>when
I printed the response.body to screen it does not contain he CSS class
declaration on the body tag, where as running mongrel and going to the
page everything is fine.
<br><br>what am I doing wrong? I ended up doing:<br><br>render "/admin/users/index.html.erb", :layout => "application"<br>response[:body_class].should == ' class="users"'<br><br>I am interested to know why my first attempt did not work.
<br></div>