RSpec 統合テストを失敗させようとしています。
次の HTML フラグメントがあるとします。
<article id="content">
<section>
<p>There aren't any travel promotions... yet!</p>
</section>
</article>
次の Rspec テストを実行すると:
describe SomeController do
render_views
describe "GET 'promotion_index'" do
it "should display an empty page given a blank page fragment and no promotions " do
get :promotion_index
response.should have_selector("#content section:first-of-type", :content => "")
end
end
end
その後、テストは失敗するはずです
しかし、そうではありません。セレクターにコンテンツがあるかどうかにかかわらず、見事に通過します。
明確にするために、<p>
コンテンツが存在しないことをテストしたくありません。<article id="content"><section /></article>
コンテンツがまったく含まれていないことをテストしたい。