rspec have_selector issue
Hello,
I am new to ruby and rails and have been following a tutorial. I created a test which should check if the response of a controller action includes a title tag with a specific content but it keeps failing. I have tested manually and it is there.
I get the following output in the console.
expected following output to contain a <title>Mike's Blog | Home</title> tag: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
It looks like I am getting totally different HTML back from my get but I don't understand why. Can anyone help me out?
*******************
* Related code *
*******************
The test in read is the one which fails:
require 'spec_helper' describe PagesController do describe "GET 'home'" do it "returns http success" do get 'home' response.should be_success end it "should have the right title" do get 'home' response.should have_selector("title", :content => "Mike's Blog | Home") end end describe "GET 'contact'" do it "returns http success" do get 'contact' response.should be_success end end describe "GET 'about'" do it "returns http success" do get 'about' response.should be_success end end end
class PagesController < ApplicationController def home end def contact end def about end end
<!DOCTYPE> <html> <head> <title>Mike's Blog | Home</title> </head> <body> <h1>Pages#home</h1> <p>Find me in app/views/pages/home.html.erb</p> </body> </html>
Please sign in to leave a comment.