2013-07-12 128 views
1

我已经在我测试的rubrous/rails的NitrousIO框中安装了rspec。我想运行一个简单的测试,但得到了一个错误:关于NitrousIO问题的rspec

[email protected]:~$ rspec thetest.rb                        
/home/action/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load suc 
h file -- test (LoadError)                            
     from /home/action/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'  
     from /home/action/thetest.rb:1:in `<top (required)>'                   
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `load'    
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `block in load_spec_ 
files'                                 
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `each'    
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `load_spec_files' 
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/command_line.rb:22:in `run'     
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/runner.rb:80:in `run'      
     from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/runner.rb:17:in `block in autorun' 

我只是有两个.RB文件,“测试”和“thetest”,这最后一个是规范,遗憾的名字,那很怪异,但我只是用NitrousIO :)

当我ommit的.RB运行“rspec的thetest”

回答

2

首先你应该结帐一些rspec的tutorial

这里有一个简单的出现同样的问题,并开始基本示例,取自here。 从上NitrousIO,类型控制台:

gem install rspec 
mkdir lib 
mkdir spec 
touch lib/bowling.rb 
touch spec/bowling_spec.rb 

LIB/bowling.rb

require 'bowling' 

describe Bowling, "#score" do 
    it "returns 0 for all gutter game" do 
    bowling = Bowling.new 
    20.times { bowling.hit(0) } 
    bowling.score.should == 0 
    end 
end 

规格/ bowling_spec.rb

class Bowling 
    def hit(pins) 
    end 

    def score 
    0 
    end 
end 

然后运行:

rspec规格/ bowling_spec.rb

+0

我的错误,我的.rb文件格式不正确。 :( –