-
-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waiting matcher #580
Comments
In general I don't think RSpec should handle this, Ruby is not, in general, asynchronous so it's up to the code under test to block and return the correct value when dealing with something that is. We also can't guarantee we wouldn't prevent the block from working as we don't know what we're waiting for. Capybara handles this for you when dealing with browsers because it knows you are waiting for an external process to do something so it is able to safely block and wait for that to finish. It doesn't do it with rack-test for example. If all you want is more detail in the error output for Capybara I'd suggest you suggest it to them! |
You could also implement this as a gem, or within your own codebase RSpec does allow you to define custom matchers. |
I agree with @JonRowe: I don't think this belongs in RSpec. You mention it's not a webapp-only problem, but in the ~5 years I've been using RSpec, I've never wanted or needed something like this. I think this could work well as an extension gem, though. If you decide to make one and need some additional extension points to integrate, let us know. |
Currently matchers like |
You can certainly override |
@myronmarston Thanks. I wrote some code (https://github.com/abotalov/waiting_rspec_matchers/blob/master/lib/waiting_rspec_matchers.rb) that just adds new "become_*" rspec matchers. I would be happy if you'll review it. |
Sounds like you've found something that works for you. That's great. |
There's also wait_for via the rspec-wait gem which is cool. |
I'd like to propose to add a matcher that will retry given block until it will match all other matchers or time expired.
The matcher is applied to other matchers (like Compound).
Usage examples:
Currently users should use some gem like retriable or some other form of
wait_until
like:So error messages don't tell what was the actual value of e.g.
find('#id')[:class]
in those cases. I think handling this issue at RSpec side instead of adding additional waiting matchers to e.g. Capybara would be a more proper solution since its not webapp-only problem.Please tell if you think the idea is good or not.
The text was updated successfully, but these errors were encountered: