我正在研究一个示例RoR应用程序,但我无法使用rspec进行测试。我有rspec安装并运行测试,但他们失败了,我不知道为什么。我运行命令:
bundle exec rspec spec/
当我跑这个;这是我收到的错误消息:
Failures:
1) PagesController GET 'home' should be successful
Failure/Error: Unable to find matching line from backtrace
NameError:
uninitialized constant ActionController::TestCase::Assertions
# /usr/lib/ruby/vendor_ruby/action_controller/integration.rb:18
# /usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/lib/webrat/integrations/rails.rb:2
# /usr/lib/ruby/gems/1.8/gems/webrat-0.7.1/lib/webrat/core/configuration.rb:105:in `mode='
# /usr/lib/ruby/gems/1.8/gems/rspec-rails-2.6.1/lib/rspec/rails/vendor/webrat.rb:26
# /usr/lib/ruby/gems/1.8/gems/webrat-
还有更多错误信息。
我不是RoR的专家,非常感谢帮助。提前谢谢。
答案 0 :(得分:1)
RSpec仅保证为Rail默认值开箱即用。从您的Gemfile中删除webrat并再次尝试。
根据教程的不同,这可能会在以后的步骤中再次破坏。
我解决这个问题的方法是删除rails的软件包安装(apt-get remove rails&& apt-get autoremove)及其依赖项,因为它显然与gem安装发生冲突。很容易理解。您可以使用gem(sudo gem install rails)安装它
答案 1 :(得分:0)
我在新的Ubuntu 11.10安装上遇到了同样的问题。
确保我使用最新版本的rspec并使用
安装了railsgem install rails
我还确保卸载ubuntu rails并没有留下任何人员
sudo apt-get autoremove
我也有红宝石1.8.7所以我切换到1.9.2
rvm use 1.9.2
我的ruby版本是问题还是autoremove删除了一些干扰。但事情发生后就开始了。