RSpec找不到嵌套格式化程序

the*_*xyz 15 ruby testing tdd rspec

我试图rspec只为Ruby(而不是Rails)运行一个简单的Ruby文件.我正在使用Ruby进行Tut + TDD测试.

我有一个competition包含lib文件夹和spec文件夹的目录.

??? lib  
?   ??? competition.rb  
?   ??? team.rb  
??? spec  
    ??? competition_spec.rb  
Run Code Online (Sandbox Code Playgroud)

当我跑步时rspec,我收到了这个错误.我之前可以发誓rspec的工作.我不知道发生了什么.

competition :> rspec spec
/Users/akh88/.rvm/gems/ruby-1.9.3-p547/gems/rspec-core-> 3.0.2/lib/rspec/core/formatters.rb:167:in `find_formatter': Formatter 'nested' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
Run Code Online (Sandbox Code Playgroud)

我的 competition_spec.rb

require_relative "../lib/competiiton.rb"  
require_relative "../lib/team.rb"  

describe Competition do
  let(:competition) {Competition.new}
  let(:team) {Team.new}

  context "having no questions" do
    before { competition.questions = [] }

    it "doesn't accept any teams" do
      expect do
        team.enter_competition(competition)
      end.to raise_error Competition::Closed
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

rvm在Mac OSX 10.9.4上,我的默认Ruby版本是1.9.1.

Mat*_*att 23

nested格式在RSpec中1使用该更名为documentation中的RSpec 2.

也许您已nested在命令行或.rspec文件中指定?然后你需要指定--format documentation.

你有没有设置config.formatter = nested某个地方,可能是你的spec_helper.rb档案?去掉它.

您可以从v1更新RSpec gem(运行测试的命令从更改specrspec尽管这样很难错过).您可以查看版本gem list rspec.

或者,您可能会错过您碰巧调用的自定义格式化程序的负载nested.


Fri*_*tzz 10

我的.rspec文件只有

--color
Run Code Online (Sandbox Code Playgroud)

我还是得到了这个错误.

我明确地将它设置为

--format documentation --color
Run Code Online (Sandbox Code Playgroud)

现在它有效.