This was a good article, but only covered the more superficial best practices concerning formatting. The more important best practices include things like, you don't need to save an object to test its validity. I see this a lot:<p><pre><code> it "returns no errors for a valid object" do
@object.save
@object.errors.size.should == 0
end
</code></pre>
This doesn't scale well and will cause your specs to run painfully slow when your project gets bigger, as the spec will hit the database every time it's run. Instead, do this:<p><pre><code> it "returns no errors for a valid object" do
@object.valid?
@object.errors.size.should == 0
end
</code></pre>
Or even better:<p><pre><code> it "returns no errors for a valid object" do
@object.should be_valid
end
</code></pre>
Neither of these actually hit the database, so the entire thing is run in-memory. And this is just one example of functional RSpec best practices. Don't get me wrong, the formatting stuff definitely helps readability across the team, but if your specs are testing the wrong thing, or running slowly, the formatting doesn't matter.