如何自定义Rspec文档格式

时间:2011-01-31 15:57:23

标签: rspec

当我执行 rspec spec 时,我会以这种方式获得测试报告:

Course Group
  Loged in
    In the new course group form
      Create a new Group course
      Create a new Group course with complex name (FAILED - 1)
      Create a new Group course with 3 subjects (FAILED - 2)

1) Course Group Loged in In the new course group form Create a new Group course with complex name
     Failure/Error: course_groupDB.courses.count.should == 1
       expected: 1
            got: 0 (using ==)
     # ./spec/acceptance/course_group_spec.rb:40:in `block (4 levels) in <top (required)>'

2) Course Group Loged in In the new course group form Create a new Group course with 3 subjects
     Failure/Error: course_groupDB.courses.count.should == 3
       expected: 3
            got: 0 (using ==)
     # ./spec/acceptance/course_group_spec.rb:54:in `block (4 levels) in <top (required)>'

注意最后,当列出失败时,名称非常混乱,因为它混合了所有上下文,描述和示例。

有没有办法像以前列出的那样显示它?

像这样:

1) Course Group 
   Loged in 
         In the new course group form 
            Create a new Group course with complex name
                Failure/Error: course_groupDB.courses.count.should == 1
                       expected: 1
                            got: 0 (using ==)
                     # ./spec/acceptance/course_group_spec.rb:40:in `block (4 levels) in <top (required)>'

  2) Course Group 
     Loged in 
        In the new course group form 
            Create a new Group course with 3 subjects
                Failure/Error: course_groupDB.courses.count.should == 3
                           expected: 3
                                got: 0 (using ==)
                         # ./spec/acceptance/course_group_spec.rb:54:in `block (4 levels) in <top (required)>'

1 个答案:

答案 0 :(得分:2)

我最终使用 Fuubar

https://github.com/jeffkreeftmeijer/fuubar

它并没有完全满足我的需求,但它是一个很好的起点。