我是工厂机器人和黄瓜的新手, 如何在步骤定义中使用factory_bot访问创建的记录? test / factories.rb
FactoryBot.define do
factory :signuser do
email 'abcd1123@test.xyz'
password 'test123'
password_confirmation 'test123'
end
end
#In console
FactoryBot.create(:signuser)
#features/test_step.rb
When (/^enter exists details for Register$/)do
#I want to access email "abcd1123@test.xyz" and password "test123" here in textfield
end
答案 0 :(得分:0)
您需要在Given
块
Given /^a user with email "(.+)"$/ do |email|
FactoryBot.create(:user, email: 'user')
end
之后,您可以在步骤中使用此用户
When (/^enter exists details for Register$/)do
fill_in 'user_email', with: User.last.email
end