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? 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... Cheers, Wincent
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: http://www.satisfice.com/blog/archives/27 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. Aslak> Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
El 18/5/2007, a las 17:32, aslak hellesoy escribi?:>> 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).Thanks for the explanation, Aslak. It''s very clear. I think a sentence or two to that effect should definitely go up on the website. Cheers, Wincent
On May 18, 2007, at 12:35 PM, Wincent Colaiuta wrote:> El 18/5/2007, a las 17:32, aslak hellesoy escribi?: > >>> 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). > > Thanks for the explanation, Aslak. It''s very clear. I think a > sentence or two to that effect should definitely go up on the website. >I just wanted to add my $0.02. I''ve started using fixtures *only* for field validations. This quickly tells me that I have a good record, that I can unset a field, and that it is invalid. Fixtures really start to become a pain, though, if the fixture has a foreign key, and so largely I stay away from them. The issue of fixtures mainly seems to be a personal preference, and largely context dependent. I think David''s advise on this one is good, though, and if you stick to that it''s hard to go wrong. Scott> Cheers, > Wincent > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users