[rspec-users] Assertions for asynchronous behaviour

Alex Chaffee
Tue, 20 Sep 2011 22:38:48 -0000

On Tue, Sep 20, 2011 at 4:55 AM, Matt Wynne <matt at mattwynne.net>
wrote:
> Thanks for all the ideas. I just rolled my own which expects a block with
an
> assertion in it:

I love the language!

    eventually { white.should be_black }

> Could we put this into RSpec somewhere?

It''s not actually RSpec-specific. I''ll put it (or probably a
hybrid
between your new code and my old code) into Wrong and you can use it
via the wrong rspec adapter.

def two
  rand(3)
end

require "rspec"
require "wrong/adapters/rspec"
describe "two" do
  it "should eventually be half of four" do
    eventually { (two + two).should == 4 }
  end
end

should work soonish...

--
Alex Chaffee - alex at stinky.com