2012-12-06 24 views
1

是否有任何現有的工具或命令來自動列出應用程序中的每個示例?自動列出所有Rspec示例

舉例來說,如果我有...

/spec/apple_spec.rb:

describe Apple do 
    it "should be round" do 
    @apple.shape.should == "round" 
    end 
    it "should be red" do 
    @apple.colour.should == "red" 
    do 
end 

/spec/banana_spec.rb:

describe Banana do 
    it "should be bent" do 
    @banana.shape.should == "bent" 
    end 
    it "should be yellow" do 
    @banana.colour.should == "yellow" 
    end 
end 

。 ..然後我正在尋找的工具或命令會產生類似於:

apple_spec.rb 
    - describe apple 
    - it should be round 
    - it should be red 
banana_spec.rb 
    - describe banana 
    - it should be bent 
    - it should be yellow 

查看此輸出將幫助我確認我測試了對我而言重要的所有行爲。

+0

默認的RSpec輸出不是基本上這樣做嗎? –

回答

0

設置format=documentation將爲所有示例生成很好的格式化輸出,包括傳遞和失敗。你可以在命令行上做到這一點:

rspec --format=documentation

還是設置添加到.rspec配置文件在你的項目的根。