Class: Doggo

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/doggo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Doggo

Returns a new instance of Doggo.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/doggo.rb', line 33

def initialize(output)
  @outstr                = output

  @example_running       = false
  @current_example_index = 0
  @group_level           = 0
  @messages              = []

  @total_count           = 0
  @pad                   = nil
  @passed_count          = 0
  @pending_count         = 0
  @failed_count          = 0

  super
end

Instance Attribute Details

#current_example_indexObject

Returns the value of attribute current_example_index.



18
19
20
# File 'lib/doggo.rb', line 18

def current_example_index
  @current_example_index
end

#example_runningObject

Returns the value of attribute example_running.



18
19
20
# File 'lib/doggo.rb', line 18

def example_running
  @example_running
end

#failed_countObject

Returns the value of attribute failed_count.



18
19
20
# File 'lib/doggo.rb', line 18

def failed_count
  @failed_count
end

#group_levelObject

Returns the value of attribute group_level.



18
19
20
# File 'lib/doggo.rb', line 18

def group_level
  @group_level
end

#messagesObject

Returns the value of attribute messages.



18
19
20
# File 'lib/doggo.rb', line 18

def messages
  @messages
end

#outstrObject

Returns the value of attribute outstr.



18
19
20
# File 'lib/doggo.rb', line 18

def outstr
  @outstr
end

#padObject

Returns the value of attribute pad.



18
19
20
# File 'lib/doggo.rb', line 18

def pad
  @pad
end

#passed_countObject

Returns the value of attribute passed_count.



18
19
20
# File 'lib/doggo.rb', line 18

def passed_count
  @passed_count
end

#pending_countObject

Returns the value of attribute pending_count.



18
19
20
# File 'lib/doggo.rb', line 18

def pending_count
  @pending_count
end

#total_countObject

Returns the value of attribute total_count.



18
19
20
# File 'lib/doggo.rb', line 18

def total_count
  @total_count
end

Instance Method Details

#example_failed(failure) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/doggo.rb', line 94

def example_failed(failure)
  self.failed_count += 1

  self.outstr.puts(failure_output(failure.example))
  self.outstr.puts(failure.fully_formatted(self.failed_count))
  self.outstr.puts("\n")

  flush_messages()

  self.example_running = false
end

#example_group_finished(_notification) ⇒ Object



68
69
70
# File 'lib/doggo.rb', line 68

def example_group_finished(_notification)
  self.group_level -= 1 if self.group_level > 0
end

#example_group_started(notification) ⇒ Object



61
62
63
64
65
66
# File 'lib/doggo.rb', line 61

def example_group_started(notification)
  self.outstr.puts() if self.group_level == 0
  self.outstr.puts("#{group_progress()}#{current_indentation}#{notification.group.description.strip}")

  self.group_level += 1
end

#example_passed(passed) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/doggo.rb', line 72

def example_passed(passed)
  self.outstr.puts(passed_output(passed.example))
  flush_messages()

  self.passed_count   += 1
  self.example_running = false
end

#example_pending(pending) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/doggo.rb', line 80

def example_pending(pending)
  self.outstr.puts(
    pending_output(
      pending.example,
      pending.example.execution_result.pending_message
    )
  )

  flush_messages()

  self.pending_count  += 1
  self.example_running = false
end

#example_started(_notification) ⇒ Object



56
57
58
59
# File 'lib/doggo.rb', line 56

def example_started(_notification)
  self.example_running        = true
  self.current_example_index += 1
end

#message(notification) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/doggo.rb', line 106

def message(notification)
  if self.example_running
    self.messages << notification.message
  else
    self.outstr.puts("#{group_progress()}#{current_indentation}#{notification.message}")
  end
end

#start(notification) ⇒ Object



50
51
52
53
54
# File 'lib/doggo.rb', line 50

def start(notification)
  self.total_count = notification.count
  self.pad         = notification.count.to_s.size
  super
end