[rspec-users] Rails View spec testing for content in <head>
rockrep at gmail.com
Fri Aug 20 13:16:52 EDT 2010
Was trying to verify content in a title tag within a head tag using
RSpec2/Rails3 and a view spec, but it seems that render/rendered API's
only return the html within the body tag. In my case the head tag is
defined in a Rails layout file, with a yield :title, and the title tag
content is set via a content_for :title section within the view, ala
Is there a way to validate head content in a view spec?
describe "users/sessions/new.html.erb" do
describe "head" do
it "should have a head" do
Failure/Error: rendered.should have_selector("head")
expected following output to contain a <head/> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
More information about the rspec-users