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:
- it's kinda ugly
- you don't have meaningfull error messages.
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 < :::: def test_home visit "/" assert_content "Homepage" within ".login" do refute_content "Signed in as" end "Sign in" find(".login"), "Sign in" assert_selector 'li:first', text: "Item 1" end end
class HomeSpec < :::: it "works" do visit "/" page.must_have_content "Homepage" within ".login" do page.wont_have_content "Signed in as" end find(".login").("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 < :::: # 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 :::: # custom methods, before blocks etc. end
Switching drivers is easy with minitest-metadata:
minitest-capybara is released under the MIT License.