2011-02-23 104 views
0

所以我使用rspec來測試我的代碼,因爲我正在經歷Rails Tutorial,當我在listing 3.20中測試代碼時,我一直收到這個錯誤。當我用眼球看着它時,所有東西都會檢查出來,但RSpec似乎並不喜歡它。RSpec沒有任何明顯的原因

(請注意,我只是做了其中一個頁面,而不是三個,因爲他們都給予同樣的錯誤)

[email protected]:~/rails_projects/sample_app$ rspec spec/controllers/pages_controller_spec.rb

F...

Failures:

1) PagesController should have the right title Failure/Error: response.should have_selector("title", expected following output to contain a | Home tag: # ./spec/controllers/pages_controller_spec.rb:13:in `block (2 levels) in '

Finished in 0.97999 seconds 4 examples, 1 failure

[email protected]:~/rails_projects/sample_app$

回答

0

在該規範文件,它說的頂部:

before(:each) do 
    # 
    # Define @base_title here. 
    # 
end 

您的規格是否爲@base_title指定了一個值?

+0

不要聽起來像一個白癡,但我的規格文件沒有**或**'@ base_title' - 沒有那樣的東西。 – jrg 2011-02-23 01:29:43

+0

對不起,我的壞,我看錯了。規範在3.19節? – zetetic 2011-02-23 01:33:13

+0

這並沒有回答,但它使我正確的方向來解決它。乾杯! – jrg 2011-02-26 13:29:01

相關問題