Cucumber 访问相关模型&x27;还没提到
我有一个引用公司的用户工厂Cucumber 访问相关模型&x27;还没提到,cucumber,pickle,factory-bot,Cucumber,Pickle,Factory Bot,我有一个引用公司的用户工厂 Factory.define :user do |f| f.first_name "John" f.last_name "Smith" f.password "test01" f.password_confirmation {|u| u.password} f.email "john.smith@example.com" f.association :company, :factory => :company end Factory.d
Factory.define :user do |f|
f.first_name "John"
f.last_name "Smith"
f.password "test01"
f.password_confirmation {|u| u.password}
f.email "john.smith@example.com"
f.association :company, :factory => :company
end
Factory.define :company do |f|
f.name "My Company"
end
该公司有许多用户。现在我希望公司有很多客户。
没有必要提及该公司,只需检查一下即可
客户机已创建,则它属于公司
Scenario: Creating a client adds them to a user's company
Given a user "John" has registered with "john.sm...@example.com",
"test01"
And I login with "john.smith@example.com", "test01"
And I am on the list of clients
When I follow "Add New Client"
When I fill in "Name" with "My Fav Client"
And I press "Create"
Then a client should exist with name: "My Fav Client"
And that client should be in my company's clients # needs the
right syntax
最后一句话是我关心的。我如何告诉Pickle用户我
am登录时,已从中获得与其关联的公司模型
工厂,所以检查该公司,看看现在是否有客户
与之相关的
谢谢,factory_girl中的关联有点棘手,也许回调(一个全新的功能)会对你有所帮助?看看