我是 Rails 新手,正在浏览rails 3 教程。我在运行集成测试时遇到问题。似乎“访问”(Webrat?)方法总是会失败。这是我从 rspec 得到的错误信息:
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 上克隆存储库时出现相同的错误。如果有人想看,这里是存储库:
git://github.com/ender4/sample_app2.git 注意那里的 2^
我已经阅读了很多类似的主题,但大多数解决方案都是针对旧版本的 rails/rspec/webrat 或其他测试框架(如 cucumber),所以我不知道它们是否/如何应用。
任何帮助,将不胜感激。