This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +35
-8
lines changed
lib/rspec/core/formatters
spec/rspec/core/formatters Expand file tree Collapse file tree 2 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,12 @@ def example_finished(example)
44
44
end
45
45
46
46
def failure_output ( example , exception )
47
- expectation_not_met = exception . is_a? ( ::RSpec ::Expectations ::ExpectationNotMetError )
48
-
49
- message = if expectation_not_met
50
- "#{ current_indentation } #{ example . description } (FAILED)"
51
- else
52
- "#{ current_indentation } #{ example . description } (ERROR)"
53
- end
47
+ red ( "#{ current_indentation } #{ example . description } (FAILED - #{ next_failure_index } )" )
48
+ end
54
49
55
- expectation_not_met ? red ( message ) : magenta ( message )
50
+ def next_failure_index
51
+ @next_failure_index ||= 0
52
+ @next_failure_index += 1
56
53
end
57
54
58
55
def passed_output ( example )
Original file line number Diff line number Diff line change
1
+ require "spec_helper"
2
+
3
+ module RSpec ::Core ::Formatters
4
+ describe DocumentationFormatter do
5
+ it "numbers the failures" do
6
+
7
+ examples = [
8
+ double ( "example 1" ,
9
+ :description => "first example" ,
10
+ :execution_result => { :status => 'failed' , :exception_encountered => Exception . new }
11
+ ) ,
12
+ double ( "example 2" ,
13
+ :description => "second example" ,
14
+ :execution_result => { :status => 'failed' , :exception_encountered => Exception . new }
15
+ )
16
+ ]
17
+
18
+ output = StringIO . new
19
+ RSpec . configuration . stub ( :output ) { output }
20
+ RSpec . configuration . stub ( :color_enabled? ) { false }
21
+
22
+ formatter = DocumentationFormatter . new
23
+
24
+ examples . each { |e | formatter . example_finished ( e ) }
25
+
26
+ output . string . should =~ /first example \( FAILED - 1\) /m
27
+ output . string . should =~ /second example \( FAILED - 2\) /m
28
+ end
29
+ end
30
+ end
You can’t perform that action at this time.
0 commit comments