我是rails的新手,正在运行 rails 3 tutorial.我在运行集成测试时遇到问题.似乎“访问”(Webrat?)方法总是会失败.这是我从rspec获得的一种错误消息: Failure/Error: visit signup_pathUnknown Webrat mod
Failure/Error: visit signup_path Unknown Webrat mode: nil Please ensure you have a Webrat configuration block that specifies a mode in your test_helper.rb, spec_helper.rb, or env.rb (for Cucumber). This configure block supercedes the need to require "webrat/<framework>". For example: Webrat.configure do |config| config.mode = :rails end # ./spec/requests/users_spec.rb:27:in `block (5 levels) in <top (required)>' # ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'
我尝试将上面的Webrat配置块添加到spec / spec_helpers.rb,我收到此错误:
Failure/Error: visit signup_path no such file to load -- action_controller/integration # ./spec/requests/users_spec.rb:27:in `block (5 levels) in <top (required)>' # ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'
我已经阅读了有关此问题的其他主题,他们建议使用’config.mode =:rack’,如果我这样做,那么我收到此错误:
Failure/Error: visit signup_path undefined method `last_response' for #<RSpec::Core::ExampleGroup::Nested_5::Nested_1::Nested_2:0xa4b8aac> # ./spec/requests/users_spec.rb:27:in `block (5 levels) in <top (required)>' # ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'
我想重要的是要注意我在win7x64上启动了教程,但我尝试使用相同的错误克隆ubuntu上的存储库.如果有人想看看,这是存储库:
混帐://github.com/ender4/sample_app2.git
注意2那里^
我已经阅读了很多类似的主题,但大多数解决方案是针对旧版本的rails / rspec / webrat或其他测试框架(如黄瓜),所以我不知道它们是否适用于/如何应用.
任何帮助,将不胜感激.
大家好…如果你看到:
失败:
1)用户注册失败不应该成为新用户
失败/错误:访问signup_path
NameError:
用于#的未定义局部变量或方法`signup_path’
…确保将测试放在正确的文件中:
它属于:
/spec/requests/users_spec.rb
不在:
/spec/model/user_spec.rb
边做边学边学习! :0<> …更容易看到另一个人撞到墙上,然后避开那条路!