How to configure minitest for integration tests using unit style

I found resources for configuring Rails to use Minitest. Unfortunately, most resources require the use of the Minitest Spec for all types of tests or, at best, at least for the integration test.

I can be "vintage", but I feel the ala test: unit statement works better for me than the rspec style. I would use the MiniTest :: Unit ad style with Capybara to run integration tests.

I am interested to see an example of minitest_helper.rb and some_model_integration_test.rb to understand the relevant configuration items that I need to create in order to make the integration test enjoyable with Capybara.

Can someone explain how to configure Rails for this?

+6
source share
1 answer

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 
+9
source

Source: https://habr.com/ru/post/910300/


All Articles