RSpec没有任何明显的原因
问题描述:
所以我使用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$
答
在该规范文件,它说的顶部:
before(:each) do
#
# Define @base_title here.
#
end
您的规格是否为@base_title
指定了一个值?
不要听起来像一个白痴,但我的规格文件没有**或**'@ base_title' - 没有那样的东西。 – jrg 2011-02-23 01:29:43
对不起,我的坏,我看错了。规范在3.19节? – zetetic 2011-02-23 01:33:13
这并没有回答,但它使我正确的方向来解决它。干杯! – jrg 2011-02-26 13:29:01