首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >要求“rspec/autorun”--不适合我

要求“rspec/autorun”--不适合我
EN

Stack Overflow用户
提问于 2014-08-02 17:10:33
回答 2查看 1.4K关注 0票数 0

有人能告诉我我做错了什么吗?

代码语言:javascript
复制
~/ruby_programs$ rspec --version
3.0.3

~/ruby_programs$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin10.0]



~/ruby_programs$ cat my_rspec.rb
require 'rspec/autorun'

describe "require 'rspec/autorun'" do
  it 'should not cause this program to throw an error' do
    true
  end

end

~/ruby_programs$ rspec my_rspec.rb 
.

Deprecation Warnings:

Requiring `rspec/autorun` when running RSpec via the `rspec` command is deprecated. Called from /Users/7stud/ruby_programs/my_rspec.rb:1:in `<top (required)>'.


If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

1 deprecation warning total

Finished in 0.00159 seconds (files took 0.16241 seconds to load)
1 example, 0 failures

我们开始:

代码语言:javascript
复制
~/ruby_programs$ ruby my_rspec.rb
my_rspec.rb:3:in `<main>': undefined method `describe' for main:Object (NoMethodError)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-08-03 06:33:48

那是因为RSpec被错过了。你应该做以下几点:

代码语言:javascript
复制
require 'rspec/autorun'

RSpec.describe "require 'rspec/autorun'" do
  it 'should not cause this program to throw an error' do
    true
  end
end
票数 2
EN

Stack Overflow用户

发布于 2017-05-03 11:32:08

尝试使用$ bundle执行rspec而不是仅使用rspec来执行rspec

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25097496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档