3
factory_girlを使用して作成したファクトリでcurrent_user(deviseの)を使用したいと思います。factory_girlファクトリ内でcurrent_userを使用する方法
私の環境が含まれています:Rubyの1.8.7を/ Railsの2.3.5 /工夫/きゅうり/ピクルス/ファクトリー・ガール
Iました次のモデルは
ユーザー:
has_many :for_me, :class_name => "Task", ....details
has_many :from_me, :class_name => "Task", ....details
タスク:
belongs_to :assigner, :class_name => "User", ....details
belongs_to :assignee, :class_name => "User", ....details
私は以下のシナリオを試しています:
Given the following users exist
| email | password |
| [email protected] | 123456 |
| [email protected] | 123456 |
And users are confirmed
And I am on the sign in page
And I am logged in as "[email protected]" with password "123456"
When I fill in "task[description]" with "description 1"
And I press "task_submit"
Then I should see "description 1"
私がしているしている工場:
Factory.define :user do |f|
f.first_name 'user_fn'
f.last_name 'user_ln'
f.sequence(:username) {|n| "user_#{n}"}
f.sequence(:email) {|n| "user_#{n}@domain.com"}
f.password '123456'
f.mobile_number ''
end
Factory.define :task do |f|
f.association :assignee, xxxxxxx
f.association :assigner, :factory => :user
end
私の問題は、私はあなたが私が推測する工場内で直接それをコーディングすることはできません代わりに、XXXXXXX