我找到了配置轨道以使用minitest的资源。遗憾的是,大多数资源都假设使用MiniSt Spp来所有测试类型,或者在最佳情况下,至少用于集成测试。

我可能是“葡萄酒”,但我觉得ALA测试的断言:单位对我来说比RSPEC样式更好。我将使用Minitest ::单位声明样式与CapyBara一起运行集成测试。

我有兴趣查看minitest_helper.rb和some_model_integration_test.rb的示例,以了解我需要放置的相关配置元素,使集成测试与Capybara有很好的工作。

有人可以解释如何为此配置Rails?

有帮助吗?

解决方案

My 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

My 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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top