Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

MiniTest expectations for Capybara

branch: master


Build Status


If you've used Capybara and RSpec, you've probably used matchers like:

page.should have_content('Title')

With CapybaraMiniTestSpec you can have similar functionality while using MiniTest::Spec:


You can also use the TestUnit style assertions:

assert_page_has_content page, 'Title'

But if you really want to be simple with MiniTest::Unit, you don't need this gem. You can do the following without this gem:

assert page.has_content?('Title'), 'Your custom failure message'

However, if you choose to use this gem, you get Capybara's failure messages as if you were using RSpec matchers.

assert_page_has_content?('<h1>Content</h1>', 'No such Text')
# fails with 'expected there to be text "No such Text" in "Content"'

You can see all the available matchers here. CapybaraMiniTestSpec iterates through those "have_x" methods and creates corresponding MiniTest assertions/expectations.


# Gemfile
gem 'capybara_minitest_spec'

NOTE: If after installing the Capybara gem, Nokogiri isn't installed, it's a known bug (



In theory, this should work with Capybara >= 2. The latest version it was tested with was Capybara 2.1.0.

For Capybara < 2 support, use a version of this gem < 1.0.


This gem was tested by basically copying the Capybara spec located in 'spec/rspec/matchers_spec.rb' and altering the test to run with MiniTest.

Something went wrong with that request. Please try again.