我有两个模型:具有以下关联的用户和汽车:
User has_many Car
Car belongs to User
我正在创建一个用于编辑汽车的功能,这是我目前所拥有的:
Feature: Edit car for a user
In order to edit cars of my user
As a user
I should be able to edit existing users related to my account
Scenario: User is signed in and edits an education with valid attributes
Given I am logged in as a user
And I have the following cars related to my account
Then I want to edit a car...
我实施的唯一步骤是这一步:
Given /^I am logged in as a user$/ do
@user = FactoryGirl.create(:user)
user_sign_in
end
def user_sign_in
visit '/users/sign_in'
fill_in "Email", :with => @user[:email]
fill_in "Password", :with => @user[:password]
click_button "Go"
end
我基本上看不到如何创建与该用户关联的汽车,以及如何测试我是否能够编辑其中一辆汽车?