Guasto del test RSPEC: le pagine statiche sulla pagina dovrebbero avere il titolo 'Chi siamo' HARTL CH.3.

StackOverflow https://stackoverflow.com//questions/12658511

  •  11-12-2019
  •  | 
  •  

Domanda

Sto lavorando attraverso il tutorial dei rotali di Michael Hartl sul tutorial delle rotaie, e sto facendo il capitolo 3 esercizi.Qualcuno può spiegare perché questo test sta fallendo?

Sto ricevendo il fallimento

rspec ./spec/requests/static_pages_spec.rb:39 # 
Static pages About page should have the title 'About Us'
.

Controller

  class StaticPagesController < ApplicationController
  def home
  end

  def help
  end

  def about
  end

  def Contact
  end
end
.

About.html.erb

<!DOCTYPE html>
<html>
<head>
<title>Ruby on Rails Tutorial Sample App | About Us</title>
</head>
<body>
<h1>About Us</h1>
.

spec.rb

describe "About page" do

  it "should have the h1 'About Us'" do
    visit '/static_pages/about'
  page.should have_selector('h1', :text => 'About Us')
end
it "should have the title 'About Us'" do
  visit '/static_pages/about'
  page.should have_selector('title',
                :text => "Ruby on Rails Tutorial Sample App | About Us")
  end
end 
.

rottes.rb

SampleApp::Application.routes.draw do
  get "static_pages/home"

  get "static_pages/help"

  get "static_pages/about"

  get "static_pages/Contact"
end
.

È stato utile?

Soluzione

Prova

page.should have_xpath("//title", :text => "About Us")
.

Altri suggerimenti

Se stai seguendo il tutorial di Mhartl e stai usando il Gem 'Capybara', posso confermare che cambiare il tuo ': testo=> ...' a ': content=> ...' renderà i tuoi testpassaggio.Grazie a @kuo jimmy .

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top