I am trying to get an RSpec integration test to fail.
Given the following HTML fragment:
<article id="content">
<section>
<p>There aren't any travel promotions... yet!</p>
</section>
</article>
When I run the following Rspec test:
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
Then the test should fail
But it doesn't. It passes beautifully whether or not there is content in the selector.
Just to be clear, I don't want to test that the <p>
content is not present. I want to test that <article id="content"><section /></article>
contains no content at all.