마이클 하트 에 의해 레일 자습서 다음 적이는 맥 OS X의 버전 3.0 레일 10.7레일스 pages_controller_spec.rb 테스트가 실패하지 않아야하지만 오류가 있습니까?
$의 RSpec에 사양/
......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
시험은 다음과 같습니다
:
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
그리고 내가 가지고있는 in 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
그리고 routes.rb에서 나는
SampleApp::Application.routes.draw do
get "pages/home"
get "pages/contact"
get "pages/about"
get "pages/help"
end
이 물론 나 또한 응용 프로그램/뷰/페이지 내가 레일 서버를 실행하고 로컬 호스트에 갈 때 이상한 것은이의 help.html.erb 페이지를 만들었 : 3000/pages/help 적절한 제목으로 적절한 페이지를 얻으므로 테스트가 통과되어야하는 것처럼 보이게하지만 아직 그렇지는 않습니다. 또한 연락처, 집 및 테스트에 대한 정보가 전달되지만 지금은 도움을 추가했을 때 알려지지 않은 이유로 도움이되지 않습니다. 이것은 정말로 나를 괴롭 히고있다, 내가 그것이 나를 미치게 만드는 것을 간과했던 간단한 해결책은 무엇인가?
변경 각각에 같은 수의 문자. 이것은 확실히 테스트 할 때 help.html.erb가 작동하지 않는 것과 관련이 있습니다. 또한 도움말의 문서 유형은 TextMate 문서이며 다른 사람들은 "문서"라고 말합니다. 이상한.. ? – Laser
나는 올바른 길을 가고 있다고 생각합니다. 코드에는 실패한 것으로 보이는 것이 없습니다. help.html.erb 파일을 삭제하고 다시 만들려고합니다. –
아이디어에 감사드립니다. 불행히도 도움이되지 않았습니다. 특히 레이크 루트가 다음과 같이 모순되는 오류가 발생하는 것은 이상합니다. http://stackoverflow.com/questions/8917201/my-computer-hates-me – Laser