$ rspec spec/ 不适合我。请帮忙
我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
Use
看起来您安装了旧版本的 rspec-rails gem。尝试更新它(2.1.0 是撰写本文时的当前版本):
更新了以下注释:
您将需要指定一个或多个规范文件的名称或包含规范文件的目录。例如,如果您的spec文件位于名为spec的文件夹中,那么这将全部运行它们:
在使用Bundler的Rails项目中:
有关rspec命令的更多信息:
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):
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:
In a Rails project using Bundler:
For more info on the rspec command:
也许已经晚了,但是对于错误:
就像它所说的,在您的 test_spec 文件中找不到测试。您应该在测试用例中添加一个“it”表达式。
Maybe is late, but for the error:
Like it says, a test wasn't found in your test_spec file. You should add an "it" expression with your test case.