Skip to content

Roles and page objects for Capybara integration testing - Formerly called Dill

License

Notifications You must be signed in to change notification settings

mojotech/capybara-ui

Repository files navigation

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)

About

Roles and page objects for Capybara integration testing - Formerly called Dill

Resources

License

Stars

Watchers

Forks

Packages

No packages published