All Projects β†’ dkarter β†’ Capybara_error_intel

dkarter / Capybara_error_intel

Licence: mit
πŸ› Ruby gem for heuristic error messages in Capybara based Page Objects

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Capybara error intel

Ifme
Free, open source mental health communication web app to share experiences with loved ones
Stars: ✭ 1,147 (+7068.75%)
Mutual labels:  rails, rspec
Mumuki Laboratory
πŸ”¬ Where students practice and receive automated and human feedback
Stars: ✭ 131 (+718.75%)
Mutual labels:  rails, rspec
Test Prof
Ruby Tests Profiling Toolbox
Stars: ✭ 1,193 (+7356.25%)
Mutual labels:  rails, rspec
Rails Api And Angularjs
Integration between rails and angularjs which includes rspec tests.
Stars: ✭ 22 (+37.5%)
Mutual labels:  rails, rspec
Action Cable Testing
Action Cable testing utils
Stars: ✭ 192 (+1100%)
Mutual labels:  rails, rspec
Action mailer matchers
ActionMailerMatchers provides rspec matchers to test Rails' common ActionMailer functionality.
Stars: ✭ 50 (+212.5%)
Mutual labels:  rails, rspec
Rspec Openapi
Generate OpenAPI schema from RSpec request specs
Stars: ✭ 129 (+706.25%)
Mutual labels:  rails, rspec
Heavens door
Capybara test scenario recorder for Rails
Stars: ✭ 857 (+5256.25%)
Mutual labels:  rails, rspec
Limestone
Boilerplate Rails 6 SaaS application with Webpack, Stimulus and Docker integration.
Stars: ✭ 191 (+1093.75%)
Mutual labels:  rails, rspec
Expertiza
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.
Stars: ✭ 160 (+900%)
Mutual labels:  rails, rspec
Lurker
πŸ“– The ultimate tool for documenting and testing APIs in Rails
Stars: ✭ 120 (+650%)
Mutual labels:  rails, rspec
Crystalball
Regression Test Selection library for your RSpec test suite
Stars: ✭ 259 (+1518.75%)
Mutual labels:  rails, rspec
Rails new
A thoughtfully designed template for building modern Rails apps. Get started in minutes instead of hours πŸ”₯πŸš€
Stars: ✭ 151 (+843.75%)
Mutual labels:  rails, rspec
Apitome
Apitome: /iˈpitΙ™mΔ“/ An API documentation presentation layer for RSpec API Documentation output.
Stars: ✭ 244 (+1425%)
Mutual labels:  rails, rspec
Shoulda Matchers
Simple one-liner tests for common Rails functionality
Stars: ✭ 3,166 (+19687.5%)
Mutual labels:  rails, rspec
Quixote
CSS unit and integration testing
Stars: ✭ 788 (+4825%)
Mutual labels:  integration-testing
Chefspec
Write RSpec examples and generate coverage reports for Chef recipes!
Stars: ✭ 825 (+5056.25%)
Mutual labels:  rspec
Graphiti
Stylish Graph APIs
Stars: ✭ 783 (+4793.75%)
Mutual labels:  rails
Materialize Sass
Materializecss rubygem for Rails Asset Pipeline / Sprockets
Stars: ✭ 785 (+4806.25%)
Mutual labels:  rails
Ordinalize full
Turns a number into an ordinal string such as first, second, third or 1st, 2nd, 3rd.
Stars: ✭ 6 (-62.5%)
Mutual labels:  rails

CapybaraErrorIntel

Build Status Code Climate Test Coverage Issue Count Gem Version downloads counter

Capybara 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.

Example

Turn this: before

Into this: after

Installation

Add this line to your application's Gemfile:

group :test do
  gem 'capybara_error_intel'
end

And then execute:

$ bundle

Or install it yourself as:

$ gem install capybara_error_intel

Usage

Simply include at the top of your PageObject, after include Capybara::DSL. Then use the built in Capybara::DSL as you are used to.

module Pages
  class PostIndex
    include Capybara::DSL
    include CapybaraErrorIntel::DSL

    def on_page?
      has_selector?('h1', text: 'Posts')
    end
  end
end

Now this page object can be used in an expressive assertion like so:

feature "User signs in" do
  scenario "redirected to posts index after sign in" do
    #... do the sign in dance
    post_index = Pages::PostIndex.new
    expect(post_index).to be_on_page
  end
end

Note: currently this gem only supports the following Capybara built-in predicate methods:

  • has_selector?(*args)
  • has_text?(*args) (and has_content? alias)
  • has_title?(title, options={})
  • has_css?(css, options={})
  • has_button?(locator, options={})
  • has_field?(locator, options={})
  • has_xpath?(xpath, options={})
  • has_checked_field?(locator, options={})
  • has_unchecked_field?(locator, options={})
  • has_select?(locator, options={})
  • has_table?(locator, options={})

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.

Accessing original predicate methods from your Page Object

If you ever need to access the overwritten Capybara predicate methods you can do so by using Capybara's page for example:

module Pages
  class PostIndex
    include Capybara::DSL
    include CapybaraErrorIntel::DSL

    def has_header?(header_text)
      page.has_selector?('h1', text: header_text)
    end
  end
end

This will allow you to have negative assertions. That being said I strongly discourage the use of negative assertions, especially with waiting Capybara methods such as has_selector? since they can make your test suite really slow.

expect(post_index_page).to_not have_header('POSTS')

Note: I'm considering changing CapybaraErrorIntel for v2 to expose the predicate methods as bang methods, both positive and negative e.g. has_selector! and has_no_selector!. Please share your thoughts in the issues section.

Development

After 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.

To 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.

Releasing a New Version

  1. Add a version header to the top of CHANGELOG.md and list all changes as bullets below the new version number
  2. Change the version number in lib/capybara_error_intel/version.rb
  3. In the project's directory run gem build capybara_error_intel.gemspec
  4. Push the gem to RubyGems gem push capybara_error_intel-##VERSION##.gem

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dkarter/capybara_error_intel

Please make sure the test suite passes and that you added tests for any new method implemented.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].