[rspec-users] Stubbing Sleep
jimmymartin at gmail.com
Tue Feb 22 22:13:28 EST 2011
Thanks, Michael: That's a useful article.
I attempted to emulate the example in RSpec but still found that stubbing
sleep with any of the built in rspec-mocks wasn't working the way I hoped. I
was probably doing something wrong.
In the end I wrote a little module (Sleepy) that I can include in
RSpec.configure, which adds the #within method to the DSL. So now I can say
something like this:
RSpec.configure do |c|
describe "some long running method" do
it "takes no longer than thirty seconds to do its work" do
within 30.seconds do
And yes; I committed horrible atrocities duck punching Fixnum and Float to
get the syntax reading nicely! :)
I suppose what I really wanted to be able to say was something like:
And be able to configure the maximum timeout of #should_eventually
Anyway, if this looks interesting or helpful for someone else I'll throw it
in a Gist.
On Wed, Feb 23, 2011 at 6:37 AM, Michael Guterl <mguterl at gmail.com> wrote:
> Eric Hodel recently blogged about this:
> Michael Guterl
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users