Capybara
shoulda-matchers
Our great sponsors
Capybara | shoulda-matchers | |
---|---|---|
20 | 5 | |
9,946 | 3,465 | |
0.3% | 0.2% | |
7.7 | 8.3 | |
about 19 hours ago | 6 days ago | |
Ruby | Ruby | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Capybara
-
16 Best Ruby Frameworks For Web Development [2024]
Cuba takes help from a lot of other technologies to bring the best of everything. For example, the responses in Cuba are the optimized version of the Rack responses. The templates are integrated via Tilt and testing via Cutest and Capybara.
-
🩰 Scheduling automated tests
I am going to use a browser based testing tool called Playwright (But you could use Capybara, or Selenium WebDriver etc.).
-
Building GitHub with Ruby on Rails
Even as a much smaller team, building Heii On-Call [0] as a lightweight alerting/monitoring/on-call rotations SaaS based on Ruby on Rails has basically been a pleasure!
And as the article highlights, perhaps the key reason for smooth deployments and upgrades is that the CI testing story is so, so good: RSpec [1] plus Capybara [2] for us. That means we have decently extensive tests of just about all behavior. The few small Rails and Ruby upgrades we've done have gone quite smoothly and confidently, with usually just a few non-Rails gem dependencies needing to be manually updated as well.
The "microservices" story is where we've pulled in the Crystal programming language [3] to great effect. After dabbling with Go and Rust, we've found that Crystal is truly a breath of fresh air. Crystal powers the parts of Heii On-Call that need to be fast and low-RAM, specifically the inbound API https://api.heiioncall.com/ and the outbound HTTP(S) prober background processes. I've ported some shared utility classes from Ruby to Crystal almost completely by just copy-and-pasting ___.rb to ___.cr; porting the tests for those classes was far more onerous than porting the class code itself. (Perhaps another point of evidence toward the superiority of RoR's testing story...)
The front-end story is nice but just a bit weaker. Using Hotwire / Turbo successfully, but I have an open PR to fix a fairly obvious stale cache bug in Turbo [4] that has been sitting unloved for nearly a month, despite other users reporting the same issue. I'm hopeful that it will get merged in the next release, but definitely less active than the backend side.
For me, the key conclusion is that the excellent Ruby on Rails testing story is what enables everything to go a lot more smoothly and have such a strong foundation. I'd be curious if any GitHubbers can talk more about whether they too are using Rspec+Capybara or something else? Are there internal guidelines for test coverage?
-
Minitest vs. RSpec in Rails
Since the Capybara library drives the underlying tests, Minitest also has the same syntax.
- Is it a common practice to test JS code in a browser instead of Node.js?
-
From partials to ViewComponents: writing reusable front-end code in Rails
The nice thing about partial templates is that templates are unit-testable with View specs (or similarly in Minitest) and the rendered output can even be verified using Capybara matchers.
-
Tip: if you're changing all your form_for to form_with, take the opportunity to make sure all forms are being tested.
To piggyback: This would be a type of browser test, so you would want to use something like Cypress (https://github.com/testdouble/cypress-rails) or Capybara (https://github.com/teamcapybara/capybara). RSpec has a good integration with Capybara. Cypress is JS-based so it will require some additional config.
- How to use undocumented web APIs
- Don't make me think, or why I switched to Rails from JavaScript SPAs
-
The Benefits of Acceptance Testing
For instance, the acceptance test above requires a log in routine. Here's where the expressive power of a DSL like Capybara manifests:
shoulda-matchers
-
How to Use Shoulda Matchers with RSpec for Ruby on Rails
According to the shoulda-matchers documentation:
-
Get help from thoughtbot for free (mentoring / office hours)
I work at thoughtbot, you might know us for our open source work like administrate, factory_bot or shoulda-matchers.
- Como configurar ambiente de testes em Ruby on Rails com RSpec
-
Top 5 Best Testing Ruby Gems For Building Ruby on Rails Web Application
4. Shoulda-matchers
What are some alternatives?
Playwright - Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Aruba - Test command-line applications with Cucumber-Ruby, RSpec or Minitest.
Emoji-RSpec - Custom Emoji Formatters for RSpec
Cucumber - A home for issues that are common to multiple cucumber repositories
RSpec - RSpec meta-gem that depends on the other components
Bacon - a small RSpec clone
stimulus-use - A collection of composable behaviors for your Stimulus Controllers
Spinach - Spinach is a BDD framework on top of Gherkin.
minitest - minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking.
Pundit Matchers - A set of RSpec matchers for testing Pundit authorisation policies.
Howitzer - A Ruby-based framework for acceptance testing