Hello list, I''m trying to setup some shared specs to describe a CRUD controller and want to reuse the logic in it. I''m basing most of the examples in latest David''s post about it [1] The thing is that looking at the mailing list I couldn''t find a cleaner way to set the model that will be used in the different controller examples. Has anyone experienced DRY without removing readability in this topic? I was looking for something like this: describe Invoices do it_should_behave_like "CRUD", :model => Invoice, ... end where :model is being set as instance variable inside the shared specs. In any case, I can workaround using before(:each) blocks before invoking the shared specs. Thanks in advance for comments, suggestions and pointers. [1] http://blog.davidchelimsky.net/2008/7/1/new-controller-examples -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams
On Sat, Aug 2, 2008 at 6:49 PM, Luis Lavena <luislavena at gmail.com> wrote:> Hello list, > > I''m trying to setup some shared specs to describe a CRUD controller > and want to reuse the logic in it. > > I''m basing most of the examples in latest David''s post about it [1] > > The thing is that looking at the mailing list I couldn''t find a > cleaner way to set the model that will be used in the different > controller examples. > > Has anyone experienced DRY without removing readability in this topic?I think it''s ironic that you cite my post about the goodness of being less DRY in your quest for more DRY-ness. ;)> I was looking for something like this: > > describe Invoices do > it_should_behave_like "CRUD", :model => Invoice, ... > endThere is an open ticket on this: http://rubyurl.com/7ZsP Please feel free to resurrect the conversation there. Cheers, David> > where :model is being set as instance variable inside the shared specs. > > In any case, I can workaround using before(:each) blocks before > invoking the shared specs. > > Thanks in advance for comments, suggestions and pointers. > > [1] http://blog.davidchelimsky.net/2008/7/1/new-controller-examples > -- > Luis Lavena > AREA 17 > - > Human beings, who are almost unique in having the ability to learn from > the experience of others, are also remarkable for their apparent > disinclination to do so. > Douglas Adams > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Tue, Aug 5, 2008 at 10:12 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Sat, Aug 2, 2008 at 6:49 PM, Luis Lavena <luislavena at gmail.com> wrote: >> Hello list, >> >> I''m trying to setup some shared specs to describe a CRUD controller >> and want to reuse the logic in it. >> >> I''m basing most of the examples in latest David''s post about it [1] >> >> The thing is that looking at the mailing list I couldn''t find a >> cleaner way to set the model that will be used in the different >> controller examples. >> >> Has anyone experienced DRY without removing readability in this topic? > > I think it''s ironic that you cite my post about the goodness of being > less DRY in your quest for more DRY-ness. ;) >Thanks I always give my best :-D>> I was looking for something like this: >> >> describe Invoices do >> it_should_behave_like "CRUD", :model => Invoice, ... >> end > > There is an open ticket on this: http://rubyurl.com/7ZsP > > Please feel free to resurrect the conversation there. >Thanks for the pointer, but after further review of my code (and a complete weekend to think about it) I''ll stick to a before :each that set the @model_class. The quest to find balance between DRY and readability is the hardest one.> Cheers, > David >Thanks David for your time answering this email. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams