Capybara integration for MiniTest::Rails.
gem install minitest-rails-capybara
This installs the following gems:
minitest minitest-rails minitest-matchers minitest-capybara capybara
Follow the instructions to configure minitest-rails
. Then add minitest-rails-capybara
to the :test
group in Gemfile:
group :development, :test do gem "minitest-rails" end group :test do gem "minitest-rails-capybara" end
Add the following to your minitest_helper.rb
file to the test
directory.
require "minitest/rails/capybara"
Generate a new acceptance test using the default generator:
rails generate integration_test CanAccessHome
And you can specify use of the MiniTest::Spec DSL by providing the --spec
option:
rails generate integration_test CanAccessHome --spec
You can now use Capybara in your acceptance tests!
require "minitest_helper" class CanAccessHomeTest < MiniTest::Rails::ActionDispatch::IntegrationTest def test_homepage_has_content visit root_path assert page.has_content?("Home#index") end end
Or, using the Spec DSL:
require "minitest_helper" describe "Can Access Home Acceptance Test" do it "has content" do visit root_path assert page.has_content?("Home#index") end end
Join the mailing list to get help or offer suggestions.
groups.google.com/group/minitest-rails
Copyright © 2012 Mike Moore
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.