自动列出所有Rspec示例

时间:2012-12-06 22:02:47

标签: ruby-on-rails 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

查看此输出将有助于我确认我已经测试了对我很重要的所有行为。

1 个答案:

答案 0 :(得分:0)

设置format=documentation将为所有示例生成格式良好的输出,传递和失败。您可以在命令行上执行此操作:

rspec --format=documentation

或者将设置添加到项目根目录中的.rspec配置文件中。