Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
> What's up will nullDB? I once saw the developper post a few message on > the mailing-list. Anyone using it with success? I saw a post by Pat Maddox and he talked about Sqlite in-memory, so I decided to give it a try using this tutorial: http://www.mathewabonyi.com/articles/2006/11/26/superfast

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
Joaquin Rivera Padron wrote: > hey there, > maybe you should take a look at solutions that fake your database in > memory > for such cases, saving your time doing all that stubbing and mocking Yeah you are right. I am refactoring (messing up?) code because I have a DB constraint, so instead of re

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Joaquin Rivera Padron
hey there, maybe you should take a look at solutions that fake your database in memory for such cases, saving your time doing all that stubbing and mocking, I don't remember right now but I think I saw some projects for such approach, maybe someone knows better than I do :-) hth joaquin __

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
By the way in Rails I am now finding myself replacing: update_attributes, create! and their friends with something that looks like: new(...) save! Then in the spec I stub the save! method so that it doesn't hit the DB, and then I can easily compare the object attributes if they are as expecte

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
> So to recap, I would test this behavior via the Paypal examples, > because that's where the behavior originates. I may or may not mock > the call to order.update_from_paypal depending on how complex it is. > > Does that make sense? Argh! I had sent you an answer but for some reason my session

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-15 Thread Pat Maddox
On Wed, Apr 15, 2009 at 9:36 AM, Fernando Perez wrote: > Hi, > > I used to have the following method: > > def Paypal.process_ipn(params) >  ... >  paypal = create!(params) >  paypal.order.update_from_ipn(completed?) > end > > That method obviously is not easily specable because of the double dot >

[rspec-users] Rate my code: refactoring from spec

2009-04-15 Thread Fernando Perez
Hi, I used to have the following method: def Paypal.process_ipn(params) ... paypal = create!(params) paypal.order.update_from_ipn(completed?) end That method obviously is not easily specable because of the double dot method call, and when specing it, it would hit the DB for nothing. I used