/capybara-minitest

Provides assertions for minitest based on Capybara's RSpec matchers.

Primary LanguageRubyMIT LicenseMIT

Capybara::Minitest

Gem Version Dependency Status Build Status Codeship Code Climate Coverage Status Inline docs

Note: the 0.9.0 and 0.9.1 gems were broken, make sure to update to 0.9.2 using $ gem install capybara-minitest.

If you're using Minitest::Test with the Capybara::DSL for your tests, this gem will allow you to do:

# With Capybara::Minitest::Assertions included
assert_has_text page, 'Squeak', 'optional message'

instead of:

# Without Capybara::Minitest
assert page.has_text?('Squeak'), 'optional message'

The assertions are dynamically generated from Capybara's RSpec matchers. You can optionally provide custom failure messages and the backtrace will be cleaned up for you.

You can see the full list of assertions (and refutations) in the auto-generated RDoc.

Install

# Gemfile
gem 'capybara-minitest'

Usage

require 'capybara/minitest/assertions'

class AcceptanceTest < Minitest::Test
  include Capybara::DSL
  include Capybara::Minitest::Assertions
end

Or, if you're using Rails:

require 'capybara/minitest/assertions'

class AcceptanceTest < ActionDispatch::IntegrationTest
  include Capybara::DSL
  include Capybara::Minitest::Assertions
end

Example

class RodentTest < Minitest::Test
  include Capybara::DSL
  include Capybara::Minitest::Assertions

  def test_squeak
    visit '/rodent'
    assert_has_text page, 'Squeak', 'optional message'
  end
end