add expert factory

This commit is contained in:
kara Diaby 2021-01-15 16:33:36 +01:00
parent da067597ab
commit efbff0f2e0
2 changed files with 15 additions and 1 deletions

14
spec/factories/expert.rb Normal file
View file

@ -0,0 +1,14 @@
FactoryBot.define do
sequence(:create_expert_email) { |n| "expert#{n}@expert.com" }
factory :expert do
transient do
email { generate(:expert_email) }
password { 'somethingverycomplated!' }
end
initialize_with do
User.create_or_promote_to_expert(email, password).expert
end
end
end

View file

@ -1,7 +1,7 @@
RSpec.describe Expert, type: :model do
describe 'an expert could be add to a procedure' do
let(:procedure) { create(:procedure) }
let(:expert) { Expert.create }
let(:expert) { create(:expert) }
before do
procedure.experts << expert