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



57
58
59
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 57

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

Instance Method Details

#run_endedObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 35

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



30
31
32
33
# File 'lib/rbehave/reporter/plain_text_reporter.rb', line 30

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

#scenario_failed(story_title, scenario_name, err) ⇒ Object



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

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



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

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

#scenario_started(story_title, scenario_name) ⇒ Object



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

def scenario_started(story_title, scenario_name)
  @out << "#{scenario_name} (#{story_title})\n" if RBehave::Runner.options.debug
end

#scenario_succeeded(story_title, scenario_name) ⇒ Object



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

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