2

在更新到 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:in require': no such file to load -- spec_helper (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire' from spec/integration/layout_links_spec.rb:1:in <top (required)>' from <internal:lib/rubygems/custom_require>:29:inrequire' from :29:in require' from -e:1:inblock in ' from -e:1:in each' from -e:1:in'

有任何想法吗?

4

1 回答 1

3

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

第二个问题可能是因为ruby​​ 1.9.2 不再将当前目录放在加载路径上。您需要从您的 spec.opts 手动将 spec/ 包含到加载路径中。

于 2010-10-10T21:29:51.840 回答