La prueba pages_controller_spec.rb de Rails no debería fallar, pero ¿es un error?
He estado siguiendo el Tutorial de Rails de Michael Hart rails versión 3.0 en mac OS X 10.7
$ rspec spec /
......FF
Failures:
1) PagesController GET 'help' should be successful
Failure/Error: get 'help'
ActionController::RoutingError:
No route matches {:controller=>"pages", :action=>"help"}
# ./spec/controllers/pages_controller_spec.rb:45:in `block (3 levels) in <top (required)>'
2) PagesController GET 'help' should have the right title
Failure/Error: get 'help'
ActionController::RoutingError:
No route matches {:controller=>"pages", :action=>"help"}
# ./spec/controllers/pages_controller_spec.rb:49:in `block (3 levels) in <top (required)>'
Finished in 0.14686 seconds
8 examples, 2 failures
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:44 # PagesController GET 'help' should be successful
rspec ./spec/controllers/pages_controller_spec.rb:48 # PagesController GET 'help' should have the right title
La prueba se ve así:
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "should be successful" do
get 'home'
response.should be_success
end
it "should have the right title" do
get 'home'
response.should have_selector("title",
:content => "Ruby on Rails Tutorial Sample App | Home")
end
end
describe "GET 'contact'" do
it "should be successful" do
get 'contact'
response.should be_success
end
it "should have the right title" do
get 'contact'
response.should have_selector("title",
:content => "Ruby on Rails Tutorial Sample App | Contact")
end
end
describe "GET 'about'" do
it "should be successful" do
get 'about'
response.should be_success
end
it "should have the right title" do
get 'about'
response.should have_selector("title",
:content => "Ruby on Rails Tutorial Sample App | About")
end
end
describe "GET 'help'" do
it "should be successful" do
get 'help'
response.should be_success
end
it "should have the right title" do
get 'help'
response.should have_selector("title",
:content => "Ruby on Rails Tutorial Sample App | Help")
end
end
end
Y tengo en pages_controller.rb
class PagesController < ApplicationController
def home
@title = "Home"
end
def contact
@title = "Contact"
end
def about
@title = "About"
end
def help
@title = "Help"
end
end
Y en routes.rb tengo
SampleApp::Application.routes.draw do
get "pages/home"
get "pages/contact"
get "pages/about"
get "pages/help"
end
Y, por supuesto, también creé una página help.html.erb en app / views / pages. Lo extraño es cuando ejecuto el servidor de rails y voy a localhost: 3000 / pages / help obtengo la página adecuada con el título adecuado, haciendo parece que la prueba debería haber pasado, pero no lo hace. Además, el contacto, el hogar y las pruebas pasan, pero cuando acabo de agregar la ayuda, no lo hace por alguna razón desconocida. Esto realmente me está molestando, ¿cuál es la solución simple que he pasado por alto que me está volviendo loco?