[rspec-users] Assertions for asynchronous behaviour

Matt Wynne matt at mattwynne.net
Wed Sep 21 06:42:49 EDT 2011


On 20 Sep 2011, at 23:38, Alex Chaffee wrote:

> 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.

Thanks!

I know it's not RSpec specific. I suppose my motivation is I want to keep the number of tools / gems we have to mention in the book to a minimum. Since we're already using RSpec in the book already it made sense to me if it became part of the RSpec assertion toolkit. I'd have thought it would be useful to other RSpec users too.

I've never used Wrong, only read about it--and I like the idea very much, I must say. Is there any danger of adverse effects (other than an extra line the Gemfile) if we have to use the Wrong RSpec adapter in the book alongside the existing vanilla RSpec assertions?

> 
> 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
> http://alexchaffee.com
> http://twitter.com/alexch

cheers,
Matt

--
Freelance programmer & coach
Author, http://pragprog.com/book/hwcuc/the-cucumber-book (with Aslak Hellesøy)
Founder, http://relishapp.com
+44(0)7974430184 | http://twitter.com/mattwynne



More information about the rspec-users mailing list