2013-06-15 3 views
2

codeschool의 rspec 과정을 실행할 때 동일한 문제가 계속 발생합니다.rspec 처음으로 작업 한 후 이러한 파일을로드 할 수 없습니다.

언급 한 바와 같이 내가 처음 비디오에 계속 클래스 좀비를 만들 때
Justins-MacBook-Pro:rubyproject Justin$ rspec spec/lib/zombie_spec.rb 
Run options: include {:focus=>true} 

All examples were filtered out; ignoring {:focus=>true} 
* 

Pending: 
    A Zombie is named Ash 
    # Not yet implemented 
    # ./spec/lib/zombie_spec.rb:3 

Finished in 0.00929 seconds 
1 example, 0 failures, 1 pending 

Randomized with seed 7259 

나는이 오류 때 나타날 내가 요청한 및 zombie_spec.rb을 작성하고 내가 적절한 출력이 아래에 나열 얻을 RSpec에 프로그램을 실행 한 후 설정합니다 rspec 다시 실행 :

Justins-MacBook-Pro:rubyproject Justin$ rspec spec/lib/zombie_spec.rb 
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- zombie (LoadError) 
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
from /Users/Justin/rubyproject/spec/lib/zombie_spec.rb:2:in `<top (required)>' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run' 
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun' 

이 후 나는 모든 것을 제거하고 rspec을 제거하고 다시 설치했습니다. 다시 시도하고 동일한 결과를 반환했습니다.

실마리가 무엇입니까?

도움을 주셔서 감사합니다.

답변

2

나는 거의 동일한 문제가 있었지만 처음에는 한 번도 작업하지 못했습니다. zombie_spec.rb 파일을 업데이트하여 zombie.rb 파일의 전체 경로를 표시하면 제대로 작동하는 것으로 보입니다.

예 : require "/home/me/ruby/spec/lib/zombie"

+0

감사합니다! – Jtanacredi

3

require_relative이 RSpec에 파일과 같은 디렉토리에서 파일을로드

1

나는 이것을 사용하고는

require_relative "zombie.rb"

0

잘 경우 근무 이 문제는 내가 같은 문제에 빠졌을 때 spec/lib 아래에 폴더를 만들었고 모든 코드와 다른 코드를 넣었습니다. spec/test 어디서 모든 테스트를 거친 후 효과가 있었습니까? 와 나는 여기 require_relative 추가 된 코드 조각

zombie_spec.rb

require 'spec_helper' 
require_relative '../lib/zombie' 

describe Zombie do 

    it "has a name called'Jack'" do 
    zb = Zombie.new 
    zb.name.should == "Jack" 
    end 

    it "has no brains" do 
    zb = Zombie.new 
    zb.should be_intelligent == false 
    end 

end 

천국이 주목해야 zombie.rb

class Zombie 
    attr_accessor :name 

    def initialize 
    @name = "Jack" 
    end 

    def intelligent? 
    false 
    end 
end 
관련 문제