Factory bot Minitest安装程序在第一次运行时失败,但在后续运行时不会失败

Factory bot Minitest安装程序在第一次运行时失败,但在后续运行时不会失败,factory-bot,minitest,ruby-on-rails-6,Factory Bot,Minitest,Ruby On Rails 6,我目前正在为一个客户解决一系列测试问题,其中一个错误让我感到困惑。它是一个集成测试类,运行四个测试。Minitest会改变它们的运行顺序,但在每次运行时,安装程序在第一次运行时最后一行失败。之后,它在所有调用上都成功。我一辈子都不明白为什么会发生这种事 下面是课堂: class StoriesControllerTest < ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers setu

我目前正在为一个客户解决一系列测试问题,其中一个错误让我感到困惑。它是一个集成测试类,运行四个测试。Minitest会改变它们的运行顺序,但在每次运行时,安装程序在第一次运行时最后一行失败。之后,它在所有调用上都成功。我一辈子都不明白为什么会发生这种事

下面是课堂:


class StoriesControllerTest < ActionDispatch::IntegrationTest
  include Devise::Test::IntegrationHelpers

  setup do
    @user = FactoryBot.create :user, :admin
    sign_in @user

    @story = FactoryBot.create :story
  end

  teardown do
    Rails.cache.clear
  end

  def valid_params
    FactoryBot.attributes_for :story
  end

  test "should get index" do
    get "#{stories_url}.json"
    assert_response :success
  end

  test "should get edit" do
    get edit_story_url(@success_story)
    assert_response :success
  end

  test "should update story" do
    patch story_url(@story), params: { story: valid_params }
    assert_redirected_to edit_story_url(@story)
  end

  test "should destroy story" do
    assert_difference("Story.count", -1) do
      delete story_url(@story)
    end

    assert_redirected_to stories_url
  end
end

类StoriesControllerTest
它出错的行是安装方法末尾的
@success\u story=FactoryBot.create:success\u story

这是错误:
ArgumentError:参数数目错误(给定0,预期为2..3)

非常感谢您的帮助