Class: Spec::Runner::Formatter::Story::PlainTextFormatter
- Inherits:
-
BaseTextFormatter
show all
- Defined in:
- lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb
Instance Attribute Summary
#output, #pending_examples
#example_group, #options, #where
Instance Method Summary
collapse
-
#collected_steps(steps) ⇒ Object
-
#initialize(options, where) ⇒ PlainTextFormatter
constructor
A new instance of PlainTextFormatter.
-
#method_missing(sym, *args, &block) ⇒ Object
-
#run_ended ⇒ Object
-
#run_started(count) ⇒ Object
-
#scenario_ended ⇒ Object
-
#scenario_failed(story_title, scenario_name, err) ⇒ Object
-
#scenario_pending(story_title, scenario_name, msg) ⇒ Object
-
#scenario_started(story_title, scenario_name) ⇒ Object
-
#scenario_succeeded(story_title, scenario_name) ⇒ Object
-
#step_failed(type, description, *args) ⇒ Object
-
#step_pending(type, description, *args) ⇒ Object
-
#step_succeeded(type, description, *args) ⇒ Object
-
#step_upcoming(type, description, *args) ⇒ Object
-
#story_ended(title, narrative) ⇒ Object
-
#story_started(title, narrative) ⇒ Object
#close, #colourise, #dump_failure, #dump_pending, #dump_summary, #example_pending, #format_backtrace
#add_example_group, #close, #dump_failure, #dump_pending, #dump_summary, #example_failed, #example_passed, #example_pending, #example_started, #start, #start_dump
Constructor Details
Returns a new instance of PlainTextFormatter.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 8
def initialize(options, where)
super
@successful_scenario_count = 0
@pending_scenario_count = 0
@pre_story_pending_count = 0
@pre_story_successful_count = 0
@failed_scenarios = []
@pending_steps = []
@previous_type = nil
@scenario_body_text = ""
@story_body_text = ""
@scenario_head_text = ""
@story_head_text = ""
@scenario_failed = false
@story_failed = false
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
162
163
164
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 162
def method_missing(sym, *args, &block) end
|
Instance Method Details
#collected_steps(steps) ⇒ Object
159
160
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 159
def collected_steps(steps)
end
|
#run_ended ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 106
def run_ended
summary_text = "#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending"
if !@failed_scenarios.empty?
@output.puts red(summary_text)
elsif !@pending_steps.empty?
@output.puts yellow(summary_text)
else
@output.puts green(summary_text)
end
unless @pending_steps.empty?
@output.puts "\nPending Steps:"
@pending_steps.each_with_index do |pending, i|
story_name, scenario_name, msg = pending
@output.puts "#{i+1}) #{story_name} (#{scenario_name}): #{msg}"
end
end
unless @failed_scenarios.empty?
@output.print "\nFAILURES:"
@failed_scenarios.each_with_index do |failure, i|
title, scenario_name, err = failure
@output.print "\n #{i+1}) "
@output.print red("#{title} (#{scenario_name}) FAILED")
@output.print red("\n #{err.class}: #{err.message}")
@output.print "\n #{err.backtrace.join("\n")}\n"
end
end
end
|
#run_started(count) ⇒ Object
30
31
32
33
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 30
def run_started(count)
@count = count
@output.puts "Running #@count scenarios\n\n"
end
|
#scenario_ended ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 95
def scenario_ended
if @scenario_failed
@story_body_text += red(@scenario_head_text)
elsif @scenario_pending
@story_body_text += yellow(@scenario_head_text)
else
@story_body_text += green(@scenario_head_text)
end
@story_body_text += @scenario_body_text
end
|
#scenario_failed(story_title, scenario_name, err) ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 79
def scenario_failed(story_title, scenario_name, err)
@options.backtrace_tweaker.tweak_backtrace(err)
@failed_scenarios << [story_title, scenario_name, err] unless @scenario_already_failed
@scenario_already_failed = true
@story_failed = true
@scenario_failed = true
scenario_ended
end
|
#scenario_pending(story_title, scenario_name, msg) ⇒ Object
88
89
90
91
92
93
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 88
def scenario_pending(story_title, scenario_name, msg)
@pending_scenario_count += 1 unless @scenario_already_failed
@scenario_pending = true
@scenario_already_failed = true
scenario_ended
end
|
#scenario_started(story_title, scenario_name) ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 64
def scenario_started(story_title, scenario_name)
@current_scenario_name = scenario_name
@scenario_already_failed = false
@scenario_head_text = "\n\n Scenario: #{scenario_name}"
@scenario_body_text = ""
@scenario_ok = true
@scenario_pending = false
@scenario_failed = false
end
|
#scenario_succeeded(story_title, scenario_name) ⇒ Object
74
75
76
77
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 74
def scenario_succeeded(story_title, scenario_name)
@successful_scenario_count += 1
scenario_ended
end
|
#step_failed(type, description, *args) ⇒ Object
149
150
151
152
153
154
155
156
157
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 149
def step_failed(type, description, *args)
found_step(type, description, true, @scenario_pending, *args)
if @scenario_pending
@scenario_body_text += yellow(" (SKIPPED)")
else
@scenario_body_text += red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
end
@scenario_ok = false
end
|
#step_pending(type, description, *args) ⇒ Object
141
142
143
144
145
146
147
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 141
def step_pending(type, description, *args)
found_step(type, description, false, true, *args)
@pending_steps << [@current_story_title, @current_scenario_name, description]
@scenario_body_text += yellow(" (PENDING)")
@scenario_pending = true
@scenario_ok = false
end
|
#step_succeeded(type, description, *args) ⇒ Object
137
138
139
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 137
def step_succeeded(type, description, *args)
found_step(type, description, false, false, *args)
end
|
#step_upcoming(type, description, *args) ⇒ Object
134
135
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 134
def step_upcoming(type, description, *args)
end
|
#story_ended(title, narrative) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 50
def story_ended(title, narrative)
if @story_failed
@output.print red(@story_head_text)
elsif @pre_story_successful_count == @successful_scenario_count &&
@pending_scenario_count >= @pre_story_pending_count
@output.print yellow(@story_head_text)
else
@output.print green(@story_head_text)
end
@output.print @story_body_text
@output.puts
@output.puts
end
|
#story_started(title, narrative) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/gems/rspec-1.1.12/lib/spec/runner/formatter/story/plain_text_formatter.rb', line 35
def story_started(title, narrative)
@pre_story_pending_count = @pending_scenario_count
@pre_story_successful_count = @successful_scenario_count
@current_story_title = title
@story_failed = false
@story_body_text = ""
@story_head_text = "Story: #{title}\n\n"
narrative.each_line do |line|
@story_head_text += " "
@story_head_text += line
end
end
|