0

我在 StackOverflow 上提到了各种答案,但我仍然无法解决这个问题。我正在共享我的 controllers_test.rb 的代码以及屏幕截图。每次我运行 rails test 时,都会显示以下错误。我已确保控制台已关闭。如果有任何其他源代码需要分享,请告诉我。

require "test_helper"

class CategoriesControllerTest < ActionDispatch::IntegrationTest
 setup do
  @category = Category.create(name: "Sports")
 end

 test "should get index" do
  get categories_url
  assert_response :success
 end

 test "should get new" do
  get new_category_url
  assert_response :success
 end

 test "should create category" do
  assert_difference('Category.count') do
   post categories_url, params: { category: { name: "Travel" } }
  end
  assert_redirected_to category_url(Category.last)
 end

 test "should show category" do
  get category_url(@category)
  assert_response :success
 end
end

在此处输入图像描述

test_helper.rb

class ActiveSupport::TestCase 
  # Run tests in parallel with specified workers
  parallelize(workers: :number_of_processors, with: :threads) 
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 
  fixtures :all 
  # Add more helper methods to be used by all tests here...
end
4

0 回答 0