Re: [rspec-users] Stubbing out Time correctly

2009-07-15 Thread Adam Anderson
Awesome! Thanks, Scott and David. That was some intense turn-around. -Adam On Tue, Jul 14, 2009 at 9:15 PM, David Chelimsky wrote: > On Mon, Jul 13, 2009 at 1:17 PM, Scott Taylor > wrote: > > > > On Jul 13, 2009, at 2:15 PM, Scott Taylor wrote: > > > >> > >> On Jul 13, 2009, at 2:12 PM, David C

Re: [rspec-users] Stubbing out Time correctly

2009-07-14 Thread David Chelimsky
On Mon, Jul 13, 2009 at 1:17 PM, Scott Taylor wrote: > > On Jul 13, 2009, at 2:15 PM, Scott Taylor wrote: > >> >> On Jul 13, 2009, at 2:12 PM, David Chelimsky wrote: >> >>> On Mon, Jul 13, 2009 at 1:04 PM, Scott Taylor >>> wrote: On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote:

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread r_j_h_box-sf
> >From: Adam Anderson > >Would using this kind of technique require me to use that intention-revealing >method to be used in place of Time.now everywhere in the app? That is what it >seems like to me and if that's the case then I couldn't see myself doing a >Find/Replace across the entire a

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Adam Anderson
Awesome! All of these are solid ways to go, Scott. There is currently an "at_exactly" method in the app's spec_helper so replacing that with time_travel seems like a good idea. Thanks for your help. -Adam On Mon, Jul 13, 2009 at 11:04 AM, Scott Taylor wrote: > > On Jul 13, 2009, at 1:46 PM, Sco

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread David Chelimsky
On Mon, Jul 13, 2009 at 1:04 PM, Scott Taylor wrote: > > On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote: > > On Jul 13, 2009, at 1:32 PM, Adam Anderson wrote: > > Thanks for the reply, Scott. > > What you describe is what is currently being done. > > now = Time.now > Time.stub!(:now).and_return(fo

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Matt Wynne
On 13 Jul 2009, at 19:17, Scott Taylor wrote: On Jul 13, 2009, at 2:15 PM, Scott Taylor wrote: On Jul 13, 2009, at 2:12 PM, David Chelimsky wrote: On Mon, Jul 13, 2009 at 1:04 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:32 PM, Adam An

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Matt Wynne
On 13 Jul 2009, at 19:12, David Chelimsky wrote: On Mon, Jul 13, 2009 at 1:04 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:32 PM, Adam Anderson wrote: Thanks for the reply, Scott. What you describe is what is currently being done. now = T

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Scott Taylor
On Jul 13, 2009, at 2:15 PM, Scott Taylor wrote: On Jul 13, 2009, at 2:12 PM, David Chelimsky wrote: On Mon, Jul 13, 2009 at 1:04 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:32 PM, Adam Anderson wrote: Thanks for the reply, Scott. What

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Scott Taylor
On Jul 13, 2009, at 2:12 PM, David Chelimsky wrote: On Mon, Jul 13, 2009 at 1:04 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:32 PM, Adam Anderson wrote: Thanks for the reply, Scott. What you describe is what is currently being done. now

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Scott Taylor
On Jul 13, 2009, at 1:46 PM, Scott Taylor wrote: On Jul 13, 2009, at 1:32 PM, Adam Anderson wrote: Thanks for the reply, Scott. What you describe is what is currently being done. now = Time.now Time.stub!(:now).and_return(foo_time) do_stuff Time.stub!(:now).and_return(now) However, this i

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Scott Taylor
On Jul 13, 2009, at 1:32 PM, Adam Anderson wrote: Thanks for the reply, Scott. What you describe is what is currently being done. now = Time.now Time.stub!(:now).and_return(foo_time) do_stuff Time.stub!(:now).and_return(now) However, this is not returning the actual time it is only returning

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Adam Anderson
Thanks for the reply, Scott. What you describe is what is currently being done. now = Time.now Time.stub!(:now).and_return(foo_time) do_stuff Time.stub!(:now).and_return(now) However, this is not returning the actual time it is only returning the time set on the first line. I need Time.now to re

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Adam Anderson
Would using this kind of technique require me to use that intention-revealing method to be used in place of Time.now everywhere in the app? That is what it seems like to me and if that's the case then I couldn't see myself doing a Find/Replace across the entire app on Time.now. If I am misunderstan

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread BJ Clark
Adam, What I usually do is extract out the original Time.now call to method somewhere (with an intention revealing name) and stub out the method instead of #now itself. - BJ Clark On Jul 13, 2009, at 9:45 AM, Adam Anderson wrote: So that is what is happening now. Time.now is being st

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Scott Taylor
On Jul 13, 2009, at 12:09 PM, Adam Anderson wrote: I can't seem to find a good way to do this. If I stub out Time.now in one of my specs but need to return it to its original functionality then can I remove the stub? So I'd like to say something like: Time.stub!(:now).and_return(foo_time)

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread Adam Anderson
So that is what is happening now. Time.now is being stubbed but that will last for the life of the spec, but I only need it to create some test data and I don't want it to affect other areas of the app after that test data has been created. Currently Time.now is being used somewhere to create a gui

Re: [rspec-users] Stubbing out Time correctly

2009-07-13 Thread doug livesey
Can you just stub it before the example in question, either in it or in a before block? 2009/7/13 Adam Anderson > I can't seem to find a good way to do this. If I stub out Time.now in one > of my specs but need to return it to its original functionality then can I > remove the stub? > > So I'd l

[rspec-users] Stubbing out Time correctly

2009-07-13 Thread Adam Anderson
I can't seem to find a good way to do this. If I stub out Time.now in one of my specs but need to return it to its original functionality then can I remove the stub? So I'd like to say something like: Time.stub!(:now).and_return(foo_time) Time.now # => foo_time Time.unstub!(:now) Time.now # => wha