<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I'm new to RSpec so excuse me if I'm missing something obvious here. I
recently renamed an attribute on a model, and my generated view spec didn&#8217;t
detect it. This resulted in a defect going through undetected. Even worse, I&#8217;m
not sure how I could reasonably get RSpec to detect such a change. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I suspect the problem isn&#8217;t specific to RSpec, but I encountered
it whilst dealing with RSpec and thought this would be a good place to ask for
advice.<br>
<br>
The details: <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I used RSpec to generate scaffolding for a model we'll call 'Resource'.
Resource has an attribute called 'entity'.<br>
<br>
It generated for me a view for a Resource - including its &#8216;entity&#8217;
attribute. It also generated a corresponding spec that looked like this:<br>
<br>
describe &quot;/resources/index.html.erb&quot; do<br>
&nbsp; include ResourcesHelper<br>
&nbsp; <br>
&nbsp; before(:each) do<br>
&nbsp;&nbsp;&nbsp; resource_98 = mock_model(Resource)<br>
&nbsp;&nbsp;&nbsp; resource_98.should_receive(<wbr>:entity).and_return(&quot;MyString&quot;)<br>
&nbsp;&nbsp;&nbsp; ...<br>
&nbsp; end<br>
&nbsp; <br>
&nbsp; it &quot;should render list of resources&quot; do<br>
&nbsp;&nbsp;&nbsp; render &quot;/resources/index.html.erb&quot;<br>
&nbsp;&nbsp;&nbsp; response.should have_tag(&quot;tr&gt;td&quot;,
&quot;MyString&quot;, 2)<br>
&nbsp;&nbsp;&nbsp; ..<br>
&nbsp; end<br>
end<br>
<br>
It also generated a fixture and model spec, which I tweaked as follows:<br>
<br>
describe Resource do<br>
&nbsp;&nbsp; fixtures :resources<br>
&nbsp; <br>
&nbsp; it &quot;should have an entity&quot; do<br>
&nbsp;&nbsp;&nbsp; resources(:one).entity.should == 'MyString'<br>
&nbsp; end<br>
end<br clear=all>
<br>
Both specs pass. Excuse the lame model spec - I'm about to get to the point.<br>
<br>
Next I decided I wanted to rename&nbsp;the 'entity' attribute to 'entities'. My
model spec failed, so I fixed it. However, the view spec didn't fail. It
expected that the view would call 'entity' on the mock Resource - and this was
indeed still the case.<br>
<br>
However, when I went and actually looked at the page, it died - the 'entity'
attribute didn't exist anymore on the model.<br>
<br>
I'm not sure how I could have picked that up with an automated test. <br>
<br>
<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Any ideas?<br>
<br>
Thanks,<br>
<br>
Ben</span></font><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><strong><b><font size=3 color="#4a5c68"
face="Times New Roman"><span style='font-size:12.0pt;color:#4A5C68'>Ben Teese</span></font></b></strong><font
size=2 color="#4a5c68" face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:#4A5C68'><br>
</span></font><strong><b><font color="#4a5c68" face="Times New Roman"><span
style='color:#4A5C68'>Senior Developer</span></font></b></strong><o:p></o:p></p>

<p class=MsoNormal><b><font size=2 color="#4a5c68" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#4A5C68;font-weight:bold'>Mobile:</span></font></b><font
size=2 color="#4a5c68" face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:#4A5C68'> +61 (0) 405 496 053<br>
<br>
<b><span style='font-weight:bold'>a</span></b> passion for excellence<br>
</span></font><b><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-weight:bold'><a href="http://www.shinetech.com/">www.shinetech.com</a></span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'><br>
<br>
</span></font><font size=1 color="#4a5c68" face=Arial><span style='font-size:
7.5pt;font-family:Arial;color:#4A5C68'>This email is intended solely for the
use of the addressee<br>
and may contain information that is confidential or privileged.<br>
If you receive this email in error please notify the sender and<br>
delete the email immediately.<br>
</span></font><font size=2 face=Arial><span style='font-size:10.0pt;font-family:
Arial'>............................................................................................................</span></font><o:p></o:p></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>