Rspec 'should have title' tests failing with Haml
I've completed the tutorial and now re-doing with Haml. The RSpec pages_controller_spec.rb "should be successful"
tests all work. The "should have the right title"
tests do not work. (ref tutorial 3.3.2) before any duplication fixes or refractoring...just duplicate titles. The site works normal...just the tests for title failing with. Can't find any issues on various forums with Rspec and Haml? Also, is it normal for RSpec failure message to be in HTML, not Haml?
PagesController GET 'home' should have the right title
Failure/Error: response.should have_selector("title",
expected following output to contain a <title>Bartel Sample App | Home</title> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Bartel's Sample App | Home</title>
</head>
&开发者_StackOverflow社区lt;body>
<h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://growing-stream-430.heroku.com/">Bartel Sample Application.</a>
</p>
</body>
</html>
# ./spec/controllers/pages_controller_spec.rb:14:in `block (3 levels) in <top (required)>'
I think this is your problem:
It looks like your test is looking for a title called "Bartel Sample App | Home" but your actual title is "Bartel's Sample App | Home". Take off the apostrophe-s (or add it to the test) and you should be green.
You should be getting your errors in HTML/ERB, not HAML, because HAML isn't used by the Ruby interpreter. It's just for your reading pleasure. It gets converted by the HAML interpreter into ERB/HTML at runtime.
精彩评论