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
detect it. This resulted in a defect going through undetected. Even
I’m not sure how I could reasonably get RSpec to detect such a change.
I suspect the problem isn’t specific to RSpec, but I encountered it
dealing with RSpec and thought this would be a good place to ask for
I used RSpec to generate scaffolding for a model we’ll call ‘Resource’.
Resource has an attribute called ‘entity’.
It generated for me a view for a Resource - including its ‘entity’
attribute. It also generated a corresponding spec that looked like this:
describe “/resources/index.html.erb” do
resource_98 = mock_model(Resource)
it “should render list of resources” do
response.should have_tag(“tr>td”, “MyString”, 2)
It also generated a fixture and model spec, which I tweaked as follows:
describe Resource do
it “should have an entity” do
resources(:one).entity.should == ‘MyString’
Both specs pass. Excuse the lame model spec - I’m about to get to the
Next I decided I wanted to rename the ‘entity’ attribute to ‘entities’.
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
was indeed still the case.
However, when I went and actually looked at the page, it died - the
attribute didn’t exist anymore on the model.
I’m not sure how I could have picked that up with an automated test.
Mobile: +61 (0) 405 496 053
This email is intended solely for the use of the addressee
and may contain information that is confidential or privileged.
If you receive this email in error please notify the sender and
delete the email immediately.