Company を参照する User ファクトリがあります
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 に伝えるにはどうすればよいので、その会社に現在関連付けられているクライアントがあるかどうかを確認します。
ありがとう