无法获得自动测试来处理我的rails项目

时间:2011-12-30 09:58:39

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-3.1 autotest

我正在尝试使用我的rails项目进行自动测试,但我仍然遇到不同的错误。

我的设置:

  • Windows 7操作系统
  • 我的rails版本是3.1.3
  • 我的红宝石版本是1.9.2p290
  • 我的ZenTest宝石是4.5(但也试过4.6.2)
  • 我最小的宝石是1.6.0(但也试过2.10.0)

首先我应该安装什么宝石?

我遇到了一堆不同的自动测试宝石并尝试了一堆不同的组合,但似乎没有任何工作。

我试过

  • gem install autotest-rails(似乎最有可能)

但也

  • gem install autotest
  • gem install autotest-standalone
  • gem install autotest-rails-pure

(源)

我有几个不同的失败,但我得到的最常见的是以下

c:\RailsInstaller\Ruby1.9.2\bin\ruby -I.;lib;test -rubygems -e "['test/unit', 'test/functional/status_controller_test.rb
', 'test/unit/helpers/status_helper_test.rb', 'test/unit/helpers/home_helper_test.rb', 'test/unit/user_test.rb', 'test/f
unctional/home_controller_test.rb', 'test/functional/playlists_controller_test.rb', 'test/unit/playlist_test.rb', 'test/
functional/registrations_controller_test.rb', 'test/unit/song_test.rb', 'test/unit/helpers/about_helper_test.rb', 'test/
unit/helpers/playlists_helper_test.rb', 'test/functional/songs_controller_test.rb', 'test/unit/helpers/registrations_hel
per_test.rb', 'test/unit/helpers/songs_helper_test.rb', 'test/functional/about_controller_test.rb'].each { |f| require f
}" | ruby c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/autotest-standalone-4.5.9/bin/unit_diff -u

c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/turn-0.8.3/lib/turn/autorun/minitest.rb:14:in `<top (required)>': MiniTest v1.6.0 is     out of date. (RuntimeError)
`gem install minitest` and add `gem 'minitest' to you test helper.

    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/turn-0.8.3/lib/turn.rb:13:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/test_help.rb:19:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from c:/RailsProjects/songrake/test/test_helper.rb:3:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from c:/RailsProjects/songrake/test/functional/status_controller_test.rb:1:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from c:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from -e:1:in `block in <main>'
    from -e:1:in `each'
    from -e:1:in `<main>'

我还尝试将gem "minitest"(具有不同版本号)的变体添加到我的gemfile中。我还尝试将一些其他gem文件添加到gemfile中。

无论如何都喜欢使用这个工具!谢谢你的帮助!

1 个答案:

答案 0 :(得分:3)

感谢这个问题,我能够弄明白......

Error running autotest on Windows 7 with Rails 3, Ruby 1.9.2

您需要的只是ZenTest宝石和自动测试纯宝石。

然后将以下内容添加到gemfile

group :test do
  gem 'ZenTest'
  gem 'autotest-rails-pure'
  gem 'minitest'
end

而不是仅仅从命令行运行"$ autotest",您需要运行"$ bundle exec autotest"


我不明白捆绑执行官做了什么但是我发现了一个探索 http://gembundler.com/

捆绑执行

运行捆绑包中附带gem的可执行文件

$ bundle exec rspec spec/models

在某些情况下,如果可执行文件恰好安装在您的系统中并且没有引入任何与您的软件包冲突的gem,那么运行没有bundle exec的可执行文件可能会有效。

然而,这是不可靠的,并且是相当痛苦的根源。即使它看起来有效,但它可能在将来或其他机器上不起作用。