Ruby on rails Rspec中的create方法

Ruby on rails Rspec中的create方法,ruby-on-rails,ruby,rspec,rspec-rails,Ruby On Rails,Ruby,Rspec,Rspec Rails,我需要理解Rspec中的这行代码 create(:practice, creator: create(:physician, password: "password123", password_confirmation: "password123" ), phone: "+1 (555) 555-5554", office: "+1 (555) 555-5555", clinic_key: "abc123") 这是什么创建功能。它不是内置的rails或ruby函数。我们有它的文档吗?它看起来像

我需要理解Rspec中的这行代码

create(:practice, creator: create(:physician, password: "password123", password_confirmation: "password123" ), phone: "+1 (555) 555-5554", office: "+1 (555) 555-5555", clinic_key: "abc123")

这是什么创建功能。它不是内置的rails或ruby函数。我们有它的文档吗?

它看起来像是从
FactoryBot
调用的
create

通常需要创建类似于
FactoryBot.create(:user)
的对象,但如果配置FactoryBot

RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods
end
(请参阅)您可以省略
FactoryBot
并使用短变量
create(:user)


因此,您的代码使用creator创建工厂
practice
,该creator是由另一家工厂
医师创建的

现在是
FactoryBot
,因此将中间行替换为:
config.include FactoryBot::Syntax::Methods