2014-08-02 2 views
0

누구나 내가 뭘 잘못하고 있는지 말할 수 있습니까? 'rspec/autorun'이 필요합니다 - 나에게 맞지 않습니다.

~/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 

여기에 우리가 간다 : RSpec 놓친 때문에

~/ruby_programs$ ruby my_rspec.rb 
my_rspec.rb:3:in `<main>': undefined method `describe' for main:Object (NoMethodError) 

답변

2

있다고. 다음을 수행해야합니다

require 'rspec/autorun' 

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

감사 RSpec에를 실행! 나는 'require'rspec/autorun''을 사용하는 프로그램의 한 예를 찾을 수 없었다! 문서는 끔찍합니다 : https://www.relishapp.com/rspec/rspec-core/docs/command-line ... 그들이 말한 것은'루비를 호출 할 때 ... 을 추가해야합니다 'rspec/autorun '하나 또는 그 이상의 spec 파일에. – 7stud

+0

@ 7stud'rspec' 명령으로 실행할 때'RSpec'으로'describe'를 호출하면 아무 것도 요구하지 않아도됩니다. 따라서'ruby'로 실행할 때 'require'rspec/autorun '을 추가하십시오. –

+0

'RSpec.describe ...'로 작성된 단일 rspec 테스트를 본 적이 없습니다. 이 경우'require rspec/autorun'을 추가 할 수 없습니다. 문서는 그것을 언급하지 않는 것에 대해 좌절하고 있습니다. – 7stud

0

봅니다 $ 번들 간부를 사용 RSpec에 대신 RSpec에의

관련 문제