Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremyf/capybara-maleficent
Wrap your Capybara matchers with sleep intervals to reduce fragility of specs.
https://github.com/jeremyf/capybara-maleficent
Last synced: 28 days ago
JSON representation
Wrap your Capybara matchers with sleep intervals to reduce fragility of specs.
- Host: GitHub
- URL: https://github.com/jeremyf/capybara-maleficent
- Owner: jeremyf
- License: apache-2.0
- Created: 2017-08-21T17:09:48.000Z (over 7 years ago)
- Default Branch: trunk
- Last Pushed: 2020-06-13T19:30:14.000Z (over 4 years ago)
- Last Synced: 2024-04-25T10:03:10.059Z (8 months ago)
- Language: Ruby
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Capybara::Maleficent
Capybara is a fantastic testing tool. In our experience, we've encountered fragile feature specs when running headless browsers.
At it's core, `Capybara::Maleficent` exposes a method for wrapping blocks of code within sleep intervals ([see `Capybara::Maleficent.with_sleep_injection`][1]), rescuing handled exceptions and trying again. Yes, this is not ideal, as it slows down potential tests. But it is far worse (again in our experience) to have a of Capybara spec fail erratically.
This gem goes a step further, when you `require 'capybara/maleficent/spindle'`, then the node matchers will automatically make use of the `.with_sleep_injection` behavior.
The nature of `Capybara::Maleficent` is such that most of the time the matching will be as fast as they can be (they're slow enough as you are leveraging a browser for this testing). However, when a failure occurs, `Capybara::Maleficent` assumes that its due to a slowness in the browser (and not an actual failure). From there, it sleeps for a bit, then tries again.
## Using
In you Gemfile:
```ruby
gem 'capybara-maleficent', require 'false'
```In your `spec/spec_helper.rb`
```ruby
require 'capybara/maleficent/spindle'
```[1]:https://github.com/jeremyf/capybara-maleficent/blob/master/lib/capybara/maleficent.rb#L16