私は次の機能を実行しています:
Scenario: viewing existing images
Given I am on the images page
And 4 images already exist
Then I should see a table containg those 4 images
And have the option to show images
And have the option to delete images
次の手順を定義します。
Given /^I am on the images page$/ do
visit(images_path)
end
Given /^(\d+) images already exist$/ do |count|
count.to_i.times {
FactoryGirl.build(:image).save!
}
end
Then /^I should see a table containg those (\d+) images$/ do |count|
page.all('table#imagesTable tr').count.should == count
end
テーブルの行を数える最後のステップは、惨めに失敗します。ヘッダー行であると私が推測する1つの行しか見つけることができません。これらはインデックスページのテストであり、手動で動作することを確認しています。FactoryGirlで作成されたオブジェクトがコントローラーを取得しないのはなぜですか?
コントローラのインデックス方式:
def index
@images = Image.all
end