我在 RoR 应用程序上使用 Cucumber 和 Capybara 进行 BDD。我有以下功能
Feature: List profiles
In order to know that the people behind the profiles are real people
As a lurker
I want to be able to find who is registed and see their profile picture
Background: Profiles have been added to the database, some with picture attached
Given some profiles exist
And I am on the home page
Scenario: Search by city, avatars should be there
When I search for a city with profiles
Then I should see some result profiles with avatar
底层 Capybara 步骤文件包含:
Then /^I should see some result profiles with avatar$/ do
page.should have_css("#profile_search_results .profile img.avatar", :count => some_profiles)
end
此步骤检查页面是否包含
<div id="#profile_search_results>
<img class="avatar" src="" />
但是...我还想检查图像是否存在(它不是损坏的图像)。
我怎样才能在我的 Capybara 步骤中做到这一点?