class RSpec::By::Formatter
Constants
- RIGHT_MARGIN
Public Class Methods
new(output)
click to toggle source
Calls superclass method
# File lib/rspec/by/formatter.rb, line 22 def initialize(output) super(output) @failed_examples = [] @bullets = [Bullet.new('', true)] end
Public Instance Methods
bullet_end(color = :white)
click to toggle source
# File lib/rspec/by/formatter.rb, line 82 def bullet_end(color = :white) bullet = @bullets.pop if bullet.nested? bullet.message = '' end offset = RIGHT_MARGIN - bullet.offset output.puts RSpec::Core::Formatters::ConsoleCodes.wrap(bullet.delta_t.rjust(offset, ' '), color) end
bullet_start(message, color = :white)
click to toggle source
# File lib/rspec/by/formatter.rb, line 70 def bullet_start(message, color = :white) unless current_bullet.nested? offset = RIGHT_MARGIN - current_bullet.offset output.print RSpec::Core::Formatters::ConsoleCodes.wrap(current_bullet.delta_t.rjust(offset, ' '), color) output.puts '' current_bullet.nest end res = indent message output.print RSpec::Core::Formatters::ConsoleCodes.wrap(res, color) @bullets.push(Bullet.new(res)) end
by_ended(message)
click to toggle source
# File lib/rspec/by/formatter.rb, line 54 def by_ended(message) bullet_end(:cyan) end
by_started(message)
click to toggle source
# File lib/rspec/by/formatter.rb, line 50 def by_started message bullet_start(message, :cyan) end
current_bullet()
click to toggle source
# File lib/rspec/by/formatter.rb, line 66 def current_bullet @bullets.last end
current_indentation()
click to toggle source
# File lib/rspec/by/formatter.rb, line 62 def current_indentation ' ' * (@bullets.size - 1) end
example_failed(failure)
click to toggle source
# File lib/rspec/by/formatter.rb, line 44 def example_failed(failure) @failed_examples << failure.example output.puts failure.fully_formatted(@failed_examples.size) bullet_end end
example_group_finished(_notification)
click to toggle source
# File lib/rspec/by/formatter.rb, line 32 def example_group_finished(_notification) @bullets.pop end
example_group_started(notification)
click to toggle source
# File lib/rspec/by/formatter.rb, line 28 def example_group_started(notification) bullet_start(notification.group.description) end
example_passed(passed)
click to toggle source
# File lib/rspec/by/formatter.rb, line 40 def example_passed(passed) bullet_end(:success) end
example_started(notification)
click to toggle source
# File lib/rspec/by/formatter.rb, line 36 def example_started(notification) bullet_start(notification.example.description) end
indent(message)
click to toggle source
# File lib/rspec/by/formatter.rb, line 58 def indent message "#{current_indentation}#{message}" end