{"id":15046919,"url":"https://github.com/dkarter/capybara_error_intel","last_synced_at":"2025-10-29T03:30:52.944Z","repository":{"id":42788642,"uuid":"68160051","full_name":"dkarter/capybara_error_intel","owner":"dkarter","description":"🐛 Ruby gem for heuristic error messages in Capybara based Page Objects","archived":false,"fork":false,"pushed_at":"2024-01-09T04:13:14.000Z","size":930,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-06T14:50:06.830Z","etag":null,"topics":["capybara","integration-testing","page-object","pageobject","rails","rspec","ruby","testing"],"latest_commit_sha":null,"homepage":"https://doriankarter.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkarter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-14T00:53:25.000Z","updated_at":"2022-07-06T23:15:34.000Z","dependencies_parsed_at":"2024-09-24T05:04:25.826Z","dependency_job_id":"8da0a02d-0c76-44d0-a3e7-0e79e210fdee","html_url":"https://github.com/dkarter/capybara_error_intel","commit_stats":{"total_commits":48,"total_committers":5,"mean_commits":9.6,"dds":0.1875,"last_synced_commit":"358fce8a68a6204a34d861f6be9f2cbf4f5cd0fe"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkarter%2Fcapybara_error_intel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkarter%2Fcapybara_error_intel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkarter%2Fcapybara_error_intel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkarter%2Fcapybara_error_intel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkarter","download_url":"https://codeload.github.com/dkarter/capybara_error_intel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238762725,"owners_count":19526460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capybara","integration-testing","page-object","pageobject","rails","rspec","ruby","testing"],"created_at":"2024-09-24T20:53:44.798Z","updated_at":"2025-10-29T03:30:51.761Z","avatar_url":"https://github.com/dkarter.png","language":"Ruby","readme":"![CapybaraErrorIntel](img/CapybaraErrorIntel.png)\n\n[![Build Status](https://travis-ci.org/dkarter/capybara_error_intel.svg?branch=master)](https://travis-ci.org/dkarter/capybara_error_intel) [![Code Climate](https://codeclimate.com/github/dkarter/capybara_error_intel/badges/gpa.svg)](https://codeclimate.com/github/dkarter/capybara_error_intel) [![Test Coverage](https://codeclimate.com/github/dkarter/capybara_error_intel/badges/coverage.svg)](https://codeclimate.com/github/dkarter/capybara_error_intel/coverage) [![Issue Count](https://codeclimate.com/github/dkarter/capybara_error_intel/badges/issue_count.svg)](https://codeclimate.com/github/dkarter/capybara_error_intel) [![Gem Version](https://badge.fury.io/rb/capybara_error_intel.svg)](https://badge.fury.io/rb/capybara_error_intel) ![downloads counter](http://ruby-gem-downloads-badge.herokuapp.com/capybara_error_intel)\n\nCapybara provides excellent error messages for its built in predicate methods: `has_selector?`, `has_text?`, `has_title?` etc., but when those are used from Page Objects while exposing predicate methods from the PageObjects themselves the error messages are lost and all we get is `expected true, got false`.  Including this module into your PageObject by adding `include CapybaraErrorIntel::DSL` after `include Capybara::DSL` will return the heuristic error messages.\n\n## Example\n\nTurn this:\n![before](img/turn_this.png)\n\nInto this:\n![after](img/into_this.png)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :test do\n  gem 'capybara_error_intel'\nend\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install capybara_error_intel\n\n## Usage\n\nSimply include at the top of your PageObject, **after** `include Capybara::DSL`.\nThen use the built in Capybara::DSL as you are used to.\n\n```ruby\nmodule Pages\n  class PostIndex\n    include Capybara::DSL\n    include CapybaraErrorIntel::DSL\n\n    def on_page?\n      has_selector?('h1', text: 'Posts')\n    end\n  end\nend\n```\n\nNow this page object can be used in an expressive assertion like so:\n\n```ruby\nfeature \"User signs in\" do\n  scenario \"redirected to posts index after sign in\" do\n    #... do the sign in dance\n    post_index = Pages::PostIndex.new\n    expect(post_index).to be_on_page\n  end\nend\n```\n\n  Note: currently this gem only supports the following Capybara built-in predicate\n  methods:\n\n  - `has_selector?(*args)`\n  - `has_text?(*args)` (and `has_content?` alias)\n  - `has_title?(title, options={})`\n  - `has_css?(css, options={})`\n  - `has_button?(locator, options={})`\n  - `has_field?(locator, options={})`\n  - `has_xpath?(xpath, options={})`\n  - `has_checked_field?(locator, options={})`\n  - `has_unchecked_field?(locator, options={})`\n  - `has_select?(locator, options={})`\n  - `has_table?(locator, options={})`\n\n\n  It should be rather trivial to add more of them. Please open an issue or submit a pull request if something you need is missing.\n\n\n### Accessing original predicate methods from your Page Object\n\nIf you ever need to access the overwritten Capybara predicate methods you can do\nso by using Capybara's `page` for example:\n\n\n```ruby\nmodule Pages\n  class PostIndex\n    include Capybara::DSL\n    include CapybaraErrorIntel::DSL\n\n    def has_header?(header_text)\n      page.has_selector?('h1', text: header_text)\n    end\n  end\nend\n\n```\n\nThis will allow you to have negative assertions. That being said I strongly\ndiscourage the use of negative assertions, especially with waiting Capybara\nmethods such as `has_selector?` since they can make your test suite really slow.\n\n```ruby\nexpect(post_index_page).to_not have_header('POSTS')\n```\n\n\u003e Note: I'm considering changing CapybaraErrorIntel for v2 to expose the\n\u003e predicate methods as bang methods, both positive and negative e.g.\n\u003e `has_selector!` and `has_no_selector!`. Please share your thoughts in the\n\u003e issues section.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Releasing a New Version\n0. Add a version header to the top of CHANGELOG.md and list all changes as\n   bullets below the new version number\n1. Change the version number in `lib/capybara_error_intel/version.rb`\n2. In the project's directory run `gem build capybara_error_intel.gemspec`\n3. Push the gem to RubyGems `gem push capybara_error_intel-##VERSION##.gem`\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/dkarter/capybara_error_intel\n\nPlease make sure the test suite passes and that you added tests for any new\nmethod implemented.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkarter%2Fcapybara_error_intel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkarter%2Fcapybara_error_intel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkarter%2Fcapybara_error_intel/lists"}