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>&lt;% body_class &quot;users&quot; %&gt;<br><br>which sets a CSS class declaration in the content_for block which is then used in the &lt;body&gt; tag in application.html.erb

 layout.<br><br>&nbsp; def body_class(class_name)<br>&nbsp;&nbsp;&nbsp; content_for(:body_class) { &quot; class=\&quot;#{class_name}\&quot;&quot; }<br>&nbsp; end<br><br><br>I was trying the following in my view spec:<br><br>template.should_receive

(:body_class).with(&quot;users&quot;)<div id="mb_0">.and_return(&#39; class=&quot;users&quot;&#39;)<br>render &quot;/admin/users/index.html.erb&quot;, :layout =&gt; &quot;application&quot;<br>response.should have_tag(&#39;
body.users&#39;)
<br><br>I get a:<br><br>Expected at least 1 element matching &quot;body.users&quot;, found 0.<br>&lt;false&gt; 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 &quot;/admin/users/index.html.erb&quot;, :layout =&gt; &quot;application&quot;<br>response[:body_class].should == &#39; class=&quot;users&quot;&#39;<br><br>I am interested to know why my first attempt did not work.
<br></div>