kanoah_rspec_formatter 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kanoah_output_formatter.rb +39 -4
- data/lib/kanoah_rspec_formatter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f214a42fcbc7e69600a91297914bf449ddbbabd4
|
4
|
+
data.tar.gz: dfa01a3942e2feb16416a136c7abb40c88e56229
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67c48b8f012309db7ffe7a8964042b4ecb976c61dd0af7d135db82339000949bd7e76841f46cf7838162a4cc11713449acd7e2969521266f66faeb5894c48ab
|
7
|
+
data.tar.gz: 49730a9a76bf7b123573d4ffe33996e010144302efb39056582c7040d58fe5f809b8166a29ef33a9976035c8b515bd4170855ba27d61ef598b0407e7064bd542
|
@@ -1,11 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'rspec/core/formatters/base_text_formatter'
|
2
|
+
class KanoahOutputFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
3
|
+
RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished,
|
4
|
+
:example_passed, :example_pending, :example_failed, :example_started
|
3
5
|
|
4
6
|
def initialize(output)
|
5
7
|
super
|
6
8
|
@group_level = 0
|
7
9
|
end
|
8
10
|
|
11
|
+
def example_started(notification)
|
12
|
+
notification.example.metadata[:step_index] = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def example_group_started(notification)
|
16
|
+
output.puts if @group_level == 0
|
17
|
+
output.puts "#{current_indentation}#{notification.group.description.strip}"
|
18
|
+
|
19
|
+
@group_level += 1
|
20
|
+
end
|
21
|
+
|
9
22
|
def example_group_finished(_notification)
|
10
23
|
@group_level -= 1
|
11
24
|
end
|
@@ -14,6 +27,11 @@ class KanoahOutputFormatter < RSpec::Core::Formatters::DocumentationFormatter
|
|
14
27
|
passed_output(passed.example)
|
15
28
|
end
|
16
29
|
|
30
|
+
def example_pending(pending)
|
31
|
+
pending_output(pending.example,
|
32
|
+
pending.example.execution_result.pending_message)
|
33
|
+
end
|
34
|
+
|
17
35
|
def example_failed(failure)
|
18
36
|
failure_output(failure.example)
|
19
37
|
end
|
@@ -21,15 +39,32 @@ class KanoahOutputFormatter < RSpec::Core::Formatters::DocumentationFormatter
|
|
21
39
|
private
|
22
40
|
|
23
41
|
def passed_output(example)
|
24
|
-
|
42
|
+
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip}", :success)
|
25
43
|
format_output(example)
|
26
44
|
end
|
27
45
|
|
46
|
+
def pending_output(example, message)
|
47
|
+
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
|
48
|
+
"(PENDING: #{message})",
|
49
|
+
:pending)
|
50
|
+
end
|
51
|
+
|
28
52
|
def failure_output(example)
|
29
|
-
|
53
|
+
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \
|
54
|
+
"(FAILED - #{next_failure_index})",
|
55
|
+
:failure)
|
30
56
|
format_output(example)
|
31
57
|
end
|
32
58
|
|
59
|
+
def next_failure_index
|
60
|
+
@next_failure_index ||= 0
|
61
|
+
@next_failure_index += 1
|
62
|
+
end
|
63
|
+
|
64
|
+
def current_indentation
|
65
|
+
' ' * @group_level
|
66
|
+
end
|
67
|
+
|
33
68
|
def format_output(example)
|
34
69
|
example.metadata[:steps].each do |step|
|
35
70
|
output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{' ' * (@group_level + 1)}step #{step[:index] + 1}: #{step[:step_name]}",current_color(step[:status]))
|