关于NitrousIO问题的rspec

关于NitrousIO问题的rspec,rspec,nitrousio,Rspec,Nitrousio,我已经在ruby/rails的测试NitrousIO盒中安装了rspec。我正在尝试运行一个简单的测试,但出现错误: action@testbox-11814:~$ rspec thetest.rb /home/action/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_r

我已经在ruby/rails的测试NitrousIO盒中安装了rspec。我正在尝试运行一个简单的测试,但出现错误:

action@testbox-11814:~$ 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'   
action@testbox-11814:~$rspec thetest.rb
/home/action/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site\u ruby/2.0.0/rubygems/core\u ext/kernel\u require.rb:45:在“require”中:无法加载suc
h文件--测试(加载错误)
from/home/action/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site\u ruby/2.0.0/rubygems/core\u ext/kernel\u require.rb:45:in'require'
from/home/action/thetest.rb:1:in`'
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_
档案
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:“加载规范文件”
from/home/action/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/command_-line.rb:22:在“运行”中
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“自动运行中的块”
我只有两个.rb文件,“test”和“thetest”,最后一个是规范,对不起,名字很奇怪,但我只是从NitrousIO开始:)


当我命令运行“rspec thetest”的.rb时,同样的问题也会出现。

首先,您应该签出一些rspec

下面是一个简单而基本的示例,取自。 在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
class Bowling
  def hit(pins)
  end

  def score
    0
  end
end
spec/bowling\u spec.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
class Bowling
  def hit(pins)
  end

  def score
    0
  end
end
然后运行:

rspec规格/保龄球规格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
class Bowling
  def hit(pins)
  end

  def score
    0
  end
end