Capybara matchers support for Minitest unit & spec.
Capybara has good support for RSpec.
If you want to use it with Minitest, you can of course write:
With this project Minitest gets all the good stuff.
capybara) works with Rails out of the box, remember to require
See example Rails app: https://github.com/wojtekmach/minitest-capybara-example.
For more features, check out: minitest-rails-capybara.
class HomeTest < Minitest::Capybara::Test def test_home visit "/" assert_content "Homepage" within ".login" do refute_content "Signed in as" end assert_link "Sign in" assert_link find(".login"), "Sign in" assert_selector 'li:first', text: "Item 1" end end
class HomeSpec < Minitest::Capybara::Spec it "works" do visit "/" page.must_have_content "Homepage" within ".login" do page.wont_have_content "Signed in as" end find(".login").must_have_link("Sign in") page.must_have_selector 'li:first', text: "Item 1" end end
Instead of inheriting directly from Minitest::Capybara::Test (or Spec) it's usually better to create a custom test base class:
# test/acceptance_test_helper.rb require "minitest/autorun" class AcceptanceTest < Minitest::Capybara::Test # custom methods, before blocks etc. end
If you need to inherit from a different base class (e.g.
ActiveSupport::TestCase) you can do this instead:
# test/acceptance_test_helper.rb require "test_helper" class AcceptanceTest < ActiveSupport::TestCase include Minitest::Capybara::Behaviour # custom methods, before blocks etc. end
Switching drivers is easy with minitest-metadata:
minitest-capybara is released under the MIT License.