All Projects → mojotech → capybara-ui

mojotech / capybara-ui

Licence: MIT License
Roles and page objects for Capybara integration testing - Formerly called Dill

Programming Languages

ruby
36898 projects - #4 most used programming language
Gherkin
971 projects

Capybara-UI

Code Climate Test Coverage

Docs here. Check out the wiki for more ideas and tips.

Overview

Capybara-UI (formerly called Dill) is a Capybara abstraction that makes it easy to define reuseable DOM "widgets", aka page objects, and introduces the concept of "roles" to allow you to easily organize your testing methods and widgets. Capybara-UI also introduces some helpers and syntactic sugar to make your testing even easier.

Before Capybara-UI

feature 'Admin new user page' do
  it 'should be able to create a new user' do
    visit('/users/new')

    within(:css, "#new_user") do
      fill_in('Name', :with => 'Example Name')
      fill_in('Password', :with => 'Password')
      select('Blue', :from => 'Favorite Color')
      click_button('Submit')
    end

    within(:css, '.alert-success') do
      expect(page).to have_content('Example Name')
    end
  end
end

After Capybara-UI

feature 'Admin new user page' do
  let(:role) { roles.admin }

  it 'should be able to create a new user' do
    role.navigate_to_new_user
    role.create_user(name: 'Example Name', password: 'Password', color: 'Blue')

    expect(role).to see :successfully_created_user, 'Example Name'
  end
end

For a more in depth tour of Capybara-UI, read the Capybara-UI walkthrough. You can also get more ideas and tips from the wiki.

Install

Add the following line to your gemfile

gem 'capybara-ui'

If using with Cucumber, add the following to your support/env.rb.

require 'capybara/ui/cucumber'

If you are using with RSpec, add the following to your spec_helper.rb or support/env.rb file.

require 'capybara/ui/rspec'

Contributing

We welcome pull requests. Please make sure tests accompany any PRs.


Curated by the good people at MojoTech.

(psst, we're hiring)

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