Class: RBehave::Reporter::PlainTextReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rbehave/reporter/plain_text_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ PlainTextReporter

Returns a new instance of PlainTextReporter.



4
5
6
7
8
9
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 4

def initialize(out)
  @out = out
  @succeeded = 0
  @failed = []
  @pending = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



53
54
55
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 53

def method_missing(meth, *args, &block)
  # ignore unexpected callbacks
end

Instance Method Details

#run_endedObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 31

def run_ended
  @out << "\n\n#@count scenarios: #@succeeded succeeded, #{@failed.size} failed, #{@pending.size} pending\n"
  unless @pending.empty?
    @out << "\nPending:\n"
    @pending.each_with_index do |pending, i|
      title, scenario_name, msg = pending
      @out << "#{i+1}) #{title} (#{scenario_name}): #{msg}\n"
    end
  end
  unless @failed.empty?
    @out << "\nFAILURES:"
    @failed.each_with_index do |failure, i|
      title, scenario_name, err = failure
      @out << %[
#{i+1}) #{title} (#{scenario_name}) FAILED
#{err.class}: #{err.message}
#{err.filtered_backtrace.join("\n")}
]
    end
  end
end

#run_started(count) ⇒ Object



26
27
28
29
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 26

def run_started(count)
  @count = count
  @out << "Running #@count scenarios:\n"
end

#scenario_failed(story_title, scenario_name, err) ⇒ Object



16
17
18
19
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 16

def scenario_failed(story_title, scenario_name, err)
  @out << 'F'
  @failed << [story_title, scenario_name, err]
end

#scenario_pending(story_title, scenario_name, msg) ⇒ Object



21
22
23
24
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 21

def scenario_pending(story_title, scenario_name, msg)
  @pending << [story_title, scenario_name, msg]
  @out << 'P'
end

#scenario_succeeded(story_title, scenario_name) ⇒ Object



11
12
13
14
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 11

def scenario_succeeded(story_title, scenario_name)
  @out << '.'
  @succeeded += 1
end