Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assertions for asynchronous behaviour

Tags:

rspec

In GOOS[1] they use an assertion called assertEventually which samples the system for a success state until a certain timeout has elapsed. This allows you to synchronise the tests with asynchronous code.

Do we have an equivalent of that in the Ruby / RSpec world already? I know capybara has wait_until { } but that's fairly rudimentary - the failure message isn't very helpful. Is there anything else already out there?

[1] http://www.growing-object-oriented-software.com/

like image 848
user1066586 Avatar asked Jul 25 '26 03:07

user1066586


1 Answers

Sure. "wait_for" is a method Brian Takita and I originally wrote for use in Selenium tests, then IIRC it made it into the Selenium gem and now lots of libraries use it (or their own version -- I make no patent claim on polling :-)). The wait_for I remember allowed you to customize the failure message. Let me go see if it's on GitHub or anything...

Ah, here's one: https://github.com/pivotal/selenium/blob/master/lib/selenium/wait_for.rb

like image 81
Asker Avatar answered Jul 28 '26 15:07

Asker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!