bdd 0.0.7 → 0.0.8

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.
@@ -1,73 +0,0 @@
1
- RSpec::Support.require_rspec_core "formatters/documentation_formatter"
2
-
3
- module Bdd
4
- module RSpec
5
- class Formatter < ::RSpec::Core::Formatters::DocumentationFormatter
6
-
7
- ::RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished,
8
- :example_started, :example_passed,
9
- :example_pending, :example_failed
10
-
11
- def example_started(notification)
12
- notification.example.metadata[:step_messages] = []
13
- end
14
-
15
- def example_passed(passed)
16
- super
17
- output.puts read_steps(passed.example)
18
- end
19
-
20
- def example_pending(pending)
21
- super
22
- output.puts read_steps(pending.example, :yellow)
23
- end
24
-
25
- def example_failed(failure)
26
- super
27
- output.puts read_steps(failure.example, :red)
28
- end
29
-
30
- private
31
-
32
- def read_steps(example, color2=nil)
33
- last_step_title = ""
34
- example.metadata[:step_messages].map do |hash|
35
- msg = hash[:msg]
36
- color = hash[:color] || color2 || :light_black
37
- if msg.is_a? Array
38
- msg0 = if msg[0] == last_step_title
39
- blank_step_title
40
- else
41
- text_with_color(msg[0], :white)
42
- end
43
- last_step_title = msg[0]
44
-
45
- msg = [msg0, text_with_color(msg[1], color)].join(' ')
46
- end
47
- # light_black doesn't really get used because the test failure prevents other messages from being added
48
- r = [next_indentation, msg]
49
- r.join(' ')
50
- end
51
- end
52
-
53
- def blank_step_title
54
- " "
55
- end
56
-
57
- def next_indentation
58
- ' ' * (@group_level+1)
59
- end
60
-
61
- private
62
-
63
- def text_with_color(text, color)
64
- if ::RSpec.configuration.color_enabled?
65
- text.colorize(color)
66
- else
67
- text
68
- end
69
- end
70
-
71
- end
72
- end
73
- end