RoRアプリケーションでBDDにCucumberとCapybaraを使用しています。imgタグが既存のイメージを指しているかどうかをテストするには?
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="" />
が含まれていることをこのステップのチェックをしかし...私はまたかどうかを確認したい:私は、次の機能
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
基礎となるカピバラは、ファイルが含まれている手順に持っています画像が存在する(壊れた画像ではない)。
私のカピバラのステップでこれを行うにはどうすればよいですか?
'img src'を作成したら、RestClientのようなものを要求し、ファイルシステムの場所を調べるのではなく、200のステータスコードと非ゼロのボディを確認する方が信頼できる可能性があります。 –
MrDanAとJon Mの答えはどちらも正しい方向を指しています。私は正解を...コメントの代わりに投稿しました。ありがとう。 – Cesar
あなたはそれがうまくいってうれしいです! – MrDanA