$ rspec spec/ 不适合我。请帮忙

发布于 2024-10-01 11:27:16 字数 1527 浏览 3 评论 0原文

我是 Rails 新手,这阻止了我。 我正在尝试运行 rspec spec/ 并收到错误。谁能帮助我吗?

这是我得到的代码:

/Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails/transactional_database_support.rb:33:未初始化的常量 Rspec::Core (NameError)
来自 /Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails.rb:1
来自 /Users/Kendall/Sites/sample_app/spec/spec_helper.rb:4
来自 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
来自 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
来自 /Users/Kendall/Sites/sample_app/spec/controllers/pages_controller_spec.rb:1
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load_spec_files'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `map'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load_spec_files'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:18:in `run'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:55:in `run_in_process'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:46:in `run'
来自 /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:10: 在 `autorun'
来自 /usr/bin/rspec:19

I am new to rails and this is stopping me.
I am trying to run rspec spec/ and I get errors. Can anyone help me?

This is the code I am getting:

/Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails/transactional_database_support.rb:33: uninitialized constant Rspec::Core (NameError)
from /Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails.rb:1
from /Users/Kendall/Sites/sample_app/spec/spec_helper.rb:4
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/Kendall/Sites/sample_app/spec/controllers/pages_controller_spec.rb:1
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `map'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:18:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:55:in `run_in_process'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:46:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:10:in `autorun'
from /usr/bin/rspec:19

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

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

发布评论

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

评论(3

半葬歌 2024-10-08 11:27:16

使用

sudo gem 更新 rspec-rails

Use

sudo gem update rspec-rails

水波映月 2024-10-08 11:27:16

看起来您安装了旧版本的 rspec-rails gem。尝试更新它(2.1.0 是撰写本文时的当前版本):

gem update rspec-rails

更新了以下注释

您将需要指定一个或多个规范文件的名称或包含规范文件的目录。例如,如果您的spec文件位于名为spec的文件夹中,那么这将全部运行它们:

rspec spec

在使用Bundler的Rails项目中:

bundle exec rspec spec

有关rspec命令的更多信息:

rspec -h

It looks like you have an older version of the rspec-rails gem installed. Try updating it (2.1.0 is the current version at the time of writing):

gem update rspec-rails

Updated following comments:

You will need to specify the name of one or more spec files or a directory containing your spec files. For example if your spec files are in a folder called spec then this will run them all:

rspec spec

In a Rails project using Bundler:

bundle exec rspec spec

For more info on the rspec command:

rspec -h
埋葬我深情 2024-10-08 11:27:16

也许已经晚了,但是对于错误:

No examples were matched. Perhaps {:unless=>#<Proc:0x00000001005b7790@/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:53>, :if=>#<Proc:0x00000001005b7970@/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:52>} is excluding everything? Finished in 0.00003 seconds 0 examples, 0 failures

就像它所说的,在您的 test_spec 文件中找不到测试。您应该在测试用例中添加一个“it”表达式。

Maybe is late, but for the error:

No examples were matched. Perhaps {:unless=>#<Proc:0x00000001005b7790@/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:53>, :if=>#<Proc:0x00000001005b7970@/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:52>} is excluding everything? Finished in 0.00003 seconds 0 examples, 0 failures

Like it says, a test wasn't found in your test_spec file. You should add an "it" expression with your test case.

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