2011-10-15 1 views
3

RSpec을 사용하는 데 어려움을 겪고 있습니다. Ruby 프로젝트에서 RSpec을 사용할 수 없습니다. RSpec 공식 홈페이지의 "지금 시작하기"섹션에 제공된 쉬운 예제조차도 : http://rspec.info/Ruby RSpec "로드 할 파일이 없습니다."오류

공식 예제에서 코드를 가져 와서 bowling.rb와 bowling_spec.rb를 만듭니다. 내가 가진 콘솔에서 RSpec에 실행하려고하면 :

require': no such file to load -- bowling (LoadError) 
from C:/.../Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
from C:/.../bowling_spec.rb:2:in `<top (required)>' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run' 
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun' 

내가 Netbans 7.0.1 내 자신의 프로젝트뿐만 아니라 Aptanda 스튜디오와 RSpec에를 실행하려고 :

rspec bowling_spec.rb --format nested 

나는이 출력을 얻을 3. 나는 항상이 같은 오류가 발생합니다. (

  • RSpec에 (2.6.0)
  • RSpec에 코어 (2.6.4)
  • RSpec에-기대 (2.6.0)
  • RSpec에-모의 객체 : 보석 목록은 다음 RSpec에 보석을 보여 2.6.0)
  • RSpec에 레일 (2.6.1)
  • RSpec에 레일 컨트롤러 (0.1.2)

이 사람이 나를 도와 드릴까요?

+1

명령 줄을 사용하여 작업 할 때 해결되었습니다. 당신은 specling/bowling_spec.rb에 bowling_spec.rb를 넣고 lib/bowling.rb에 bowling.rb를 넣어서 작동시켜야합니다. Netbeans 및 Aptana 들어 여전히 동일한 오류가 발생합니다. – gaussd

+1

'require 'bowling'' (또는'bowling.rb '이 필요합니다)를 사용하여 파일을로드하고 있습니까? 그렇다면'require './path/to/bowling.rb''을 사용하거나'lib' 디렉토리를로드 경로에 추가 할 수 있습니다. – Frost

+0

.rb를 직접 요구할 필요는 거의 없습니다. 그리고 그렇게한다면 왜 당신이 그 일을하는지 알 것입니다. – d11wtq

답변

1

넷빈은 RSpec에 버전 2를 지원하지 않기 때문에 maunally, RSpec에 설치하는 너무 넷빈즈에서 일하기를 얻기를위한 솔루션 :도, 나는이 문제를 가지고 후세를 들어

gem install rspec -v 1.3.2 
1

을하고, 문제는 필자가 실수로 require 'spec_helper.rb을 보석의 비표준 클래스에 넣었다는 것이 었습니다. 은 재미있었습니다.