运行 rspec Gem

发布于 2024-12-12 04:28:11 字数 3658 浏览 0 评论 0原文

当我运行 $ rspec spec/ 时,我收到此错误:

You must use ANSICON 1.31 or later (http://adoxa.110mb.com/ansicon/) to use colour on Windows
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rspec-core 2.7.1,but your Gemfile requires rspec-core 2.0.1. Consider using bundle exec. (Gem::LoadError) from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:17:in `setup'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler.rb:107:in `setup'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/setup.rb:7:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:59:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:59:in `rescue in require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:35:in `require'
    from c:/Sites/app2/config/boot.rb:6:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/config/application.rb:1:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/config/environment.rb:2:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/spec/spec_helper.rb:3:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/spec/controllers/pages_controller_spec.rb:1:in `<top
(required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `load'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `map'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/command_line.rb:18:in `run'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:80:in `run_in_process'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:69:in `run' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'k in autorun'

我安装了 rspec 和 rspec-core:

bundle show rspec

C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-2.0.1

bundle show rspec-core

C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.0.1

我需要做什么才能运行 rspec?

When I run $ rspec spec/ I receive this error:

You must use ANSICON 1.31 or later (http://adoxa.110mb.com/ansicon/) to use colour on Windows
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rspec-core 2.7.1,but your Gemfile requires rspec-core 2.0.1. Consider using bundle exec. (Gem::LoadError) from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:17:in `setup'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler.rb:107:in `setup'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/setup.rb:7:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:59:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:59:in `rescue in require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:35:in `require'
    from c:/Sites/app2/config/boot.rb:6:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/config/application.rb:1:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/config/environment.rb:2:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/spec/spec_helper.rb:3:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
    from c:/Sites/app2/spec/controllers/pages_controller_spec.rb:1:in `<top
(required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `load'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `map'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/command_line.rb:18:in `run'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:80:in `run_in_process'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:69:in `run' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'k in autorun'

I have rspec and rspec-core installed:

bundle show rspec

C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-2.0.1

bundle show rspec-core

C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.0.1

What do I need to do to run rspec?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天 2024-12-19 04:28:11

嗯,解决方案就在错误消息中:

考虑使用捆绑执行程序。

所以你输入:

$ bundle exec rspec spec/

但这是要输入的字符的两倍!不能有那个!因此,请考虑 bundle install --binstubs

执行一次:

$ bundle install --binstubs          

现在这“正常工作”

$ rspec spec/

Well, the solution is right in the error message:

Consider using bundle exec.

So you type:

$ bundle exec rspec spec/

But that's twice as many characters to type! Can't have that! So consider bundle install --binstubs:

Do this once:

$ bundle install --binstubs          

Now this "just works"

$ rspec spec/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文