我有一个引用公司的用户工厂
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 我登录的用户在工厂有一个与之关联的公司模型,因此请检查该公司以查看现在是否有与之关联的客户。
谢谢