[rspec-users] Fixtures considered harmful?
aslak.hellesoy at gmail.com
Fri May 18 11:32:49 EDT 2007
On 5/18/07, Wincent Colaiuta <win at wincent.com> wrote:
> I'm trying to get really serious about doing true BDD for a new Rails
> project, and I note that at <http://rspec.rubyforge.org/documentation/
> rails/index.html> it says:
> "we really don't recommend the use of rails fixtures"
> On the same page it also says (about Model specs):
> "these are the only specs that we feel should actually interact with
> the database"
> But looking, for example, at the examples at <http://
> rspec.rubyforge.org/documentation/rails/writing/models.html>, almost
> all of them use fixtures. Can someone please clarify why use of
> fixtures are not recommended?
We should get this up on the web page, but I'll provide some insight
here. The reason why we don't recommend them is along the lines why
we're not crazy about DRYing up specs. Let me repeat David's Agile
Spec Manifesto (of which I am the second subscriber):
We prefer clear spec over well factored specs. (Clarity is king).
When everything is in your face you can picture it easier than when
it's in several different locations (fixture files, helper files etc).
> Anyone care to recommend an active, open source Rails project that's
> using RSpec and which is an exemplar of "best practice"? I'd really
> like to get things right first time, if I can...
I definitely gave up the term "Best Practice" after reading this blog:
All I can say is that in most situations I prefer to work without
fixtures, but there are a few situations where they might be useful.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users