Ruby on Rails / Capybara

Not as obvious or straightforward as it should be, since most Capybara code is based on RSpec, but Rails 4 comes with Minitest by default. Based on this Rails 3 guide:

  1. Add new bundles and run bundle install:
gem 'capybara'
gem 'launchy'
  1. Create a new test/integration_test_helper.rb, just like the existing test_helper.rb there, to import all of the Capybara DSL methods:
require "test_helper"
require "capybara/rails"

module ActionDispatch
  class IntegrationTest
    include Capybara::DSL
  1. Create a test under test/integration/create_player_test.rb (this extends the same normal integration tests superclass ActionDispatch::IntegrationTest):
require "integration_test_helper"

class CreatePlayerTest < ActionDispatch::IntegrationTest
  setup do
    @user = "Test user", provider: "testing")

  teardown do

  def do_login!
    # login through test method
    visit "/sessions/test?id=#{}"
    assert_equal "/player/new", current_path

  test "create a new player" do

    visit "/player/new"
    assert page.has_field?("Name", with:
    click_button "Start playing"

    assert page.has_content?("You are currently at Home")

  1. Run your tests with rake test:integration (which will also be run as part of rake test).

Assertions such as expect(current_path).to == "/player/new" and current_path.should == "/player/new" are RSpec idioms, and they won’t work with Minitest assertions.

Optionally you may wish to add the capybara_minitest_spec gem so you can have more informational failure messages: