我正在尝试关注TDD上的在线教程hereRuby on Rails TDD;测试时出错
在测试第一个应用程序时,出现错误。
我spec.rb代码是这样的:
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
end
运行测试后,我得到这个错误:
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for # <RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa833e5c># ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'
我会很感激你的帮助。
这是否有帮助:http://stackoverflow.com/questions/8862967/visit-method-not-found-in-my-rspec – wintersolutions 2012-03-08 11:42:14
什么是文件的路径和名称?它是spec/requests/static_pages_spec.rb像在教程中一样吗?我发现Rspec对于它的可用性和包含测试助手和基于文件名称的方法是相当“神奇”的。 – berkes 2012-03-08 11:43:05