it "should find the div" do
response.should have_selector("#section")
end
it "should not find missing text in a have_selector block" do
render "/admin/test/html.haml"
response.should have_selector("#section") do |div|
div.should_not contain("asdfjkl")
end
end

Here's another workaround which is especially useful in case of
nested have_selector() blocks.

it "should not find missing text in a have_selector block" do
render "/admin/test/html.haml"
response.should have_selector("#section") do |div|
div.should have_selector("#sub-section") do |subdiv|
not subdiv.to_s.include?("asdfjkl")
end
end
end

I had a problem that may be related. This test was failing when
it should have passed:

When /^I should see an enabled "([^\"]*)" for the user named "([^\"]*)"$/ do |action, name|
user = User.find_by_first(name)
response.should have_selector("#people__users-list-#{user.id}-row") do |scope|
scope.inner_html.should have_tag("a", action)
scope.inner_html.should_not have_tag("a.disabled", action)
end
end

I was able to make it work simply by reversing the order of the
inner_html tests:

When /^I should see an enabled "([^\"]*)" for the user named "([^\"]*)"$/ do |action, name|
user = User.find_by_first(name)
response.should have_selector("#people__users-list-#{user.id}-row") do |scope|
scope.inner_html.should_not have_tag("a.disabled", action)
scope.inner_html.should have_tag("a", action)
end
end