我找到了配置Rails以使用Minitest的资源.遗憾的是,大多数资源都假设Minitest Spec适用于所有测试类型,或者在最好的情况下,至少用于集成测试.
我可能是“复古”,但我觉得断言是一个测试:单位工作对我来说比rspec风格更好.我将使用MiniTest :: Unit声明样式与Capybara一起运行集成测试.
我有兴趣看到minitest_helper.rb和some_model_integration_test.rb的示例,以了解我需要采用的相关配置元素,以使集成测试与Capybara完美配合.
有人可以解释如何为此配置Rails吗?
解决方法
我的articles_integration_test.rb:
require 'test_helper' class ArticlesIntegrationTest < IntegrationTest def test_shows_article_title article = Article.create!(title: 'Foo bar') visit article_path(article) assert page.has_content?('Foo bar') end end@H_301_13@我的test_helper.rb:
ENV["RAILS_ENV"] = "test" require File.expand_path("../../config/environment",__FILE__) require "minitest/autorun" require "capybara/rails" require "active_support/testing/setup_and_teardown" class IntegrationTest < MiniTest::Unit::TestCase include Rails.application.routes.url_helpers include Capybara::DSL end@H_301_13@