Rails 3 - 如何获得Rspec规格/&自动测试工作?

时间:2010-10-08 16:11:57

标签: ruby-on-rails rspec autotest

在我更新到Rails 3之前,我完全使用Rspec和Autotest进行设置。

运行rspec spec /我得到了:

* spec/spec.opts is deprecated.
* please use ./.rspec or ~/.rspec instead.

我尝试将spec.opts更改为spec.rspec并再次运行rspec spec /。但现在我收到了一大堆警告:

DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated:

DEPRECATION WARNING: reset_javascript_include_default is deprecated. Please manipulate config.action_view.javascript_expansions[:defaults] directly. 

DEPRECATION WARNING: RAILS_ENV is deprecated. Please use ::Rails.env.

DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated:

DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/.

自动测试也不起作用。我得到了:

.rvm/rubies/ruby-1.9.2-p0/bin/ruby -I.:lib:test -rubygems -e "['test/unit', 'spec/integration/layout_links_spec.rb', 'test/unit/color_test.rb', 'test/functional/products_controller_test.rb', 'spec/integration/users_spec.rb', 'test/functional/colors_controller_test.rb', 'test/unit/product_test.rb', 'test/unit/helpers/products_helper_test.rb', 'test/unit/helpers/colors_helper_test.rb'].each { |f| require f }" | .rvm/gems/ruby-1.9.2-p0/gems/autotest-4.3.2/bin/unit_diff -u

:29:require': no such file to load -- spec_helper (LoadError) from <internal:lib/rubygems/custom_require>:29:in要求'     from spec / integration / layout_links_spec.rb:1:in <top (required)>' from <internal:lib/rubygems/custom_require>:29:in require'     来自:29:在require' from -e:1:in街区'     来自-e:1:each' from -e:1:in'

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

弃用警告是因为您升级到Rails 3,而不是因为RSpec。 Rails 3具有非常不同的架构,API也发生了重大变化。您是否通过rails_upgrade插件运行项目?另外,请查看Rails 3 Release Notes以获取有关修复依赖于已弃用功能的应用程序部分的帮助。

第二个问题可能是因为ruby 1.9.2 no longer puts the current directory on the load path。您需要手动将spec / /包含在spec.opts的加载路径中。