Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create method in Rspec

I need to understand this line of code in Rspec.

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

What is this create function. It is not built in rails or ruby function. Do we have its documentation?

like image 886
Adnan Ali Avatar asked Jan 14 '15 06:01

Adnan Ali


1 Answers

It looks like create is called from FactoryBot.

Usually you need to create object like FactoryBot.create(:user) but if you configure factory bot

RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods
end

(see this) you can omit FactoryBot and use short variant create(:user).

So your code creates factory practice with creator which is created by another factory physician.

like image 170
gotva Avatar answered Nov 08 '22 21:11

gotva