class RSpecLive::Display

Public Class Methods

new(suite, detail) click to toggle source
# File lib/rspec-live/display.rb, line 5
def initialize(suite, detail)
  @suite = suite
  @detail = detail
  @screen = Screen.new
end

Public Instance Methods

update() click to toggle source
# File lib/rspec-live/display.rb, line 11
def update
  @screen.start_frame
  show_header
  show_summary
  show_details
  @screen.end_frame
end
update_required?() click to toggle source
# File lib/rspec-live/display.rb, line 19
def update_required?
  @screen.update_required?
end

Private Instance Methods

character() click to toggle source
# File lib/rspec-live/display.rb, line 57
def character
  {:unknown => "?", :passed => ".", :failed => "F", :pending => "*"}
end
color() click to toggle source
# File lib/rspec-live/display.rb, line 61
def color
  {:unknown => :blue, :passed => :green, :failed => :red, :pending => :yellow}
end
show_details() click to toggle source
# File lib/rspec-live/display.rb, line 39
def show_details
  @screen.print "\n\n"
  last_failed = true
  bullet_width = (@detail.detailed_examples.length-1).to_s.length
  @detail.detailed_examples.each_with_index do |example, index|
    bullet = "#{index+1}.".rjust(bullet_width+1, " ")
    @screen.print "\n" if (!last_failed && example.failed?)
    @screen.print "#{bullet} #{example.details @detail.verbosity}", {
      :color => color[example.status],
      :wrap => true,
      :hanging_indent => (bullet_width + 1)
    }
    @screen.print "\n"
    @screen.print "\n" if example.failed?
    last_failed = example.failed?
  end
end
show_header() click to toggle source
# File lib/rspec-live/display.rb, line 25
def show_header
  @screen.print "RSpec summary for #{File.basename Dir.pwd} (#{@suite.activity_status})\n"
  @screen.print "Keys: A:show/hide-all N:next V:verbosity R:rerun Q:quit", :color => :blue
end
show_summary() click to toggle source
# File lib/rspec-live/display.rb, line 30
def show_summary
  @screen.print "\n\n"
  @suite.ordered_examples.map(&:status).each do |status|
    @screen.print character[status], :color => color[status]
  end
  @screen.print "\n\n"
  @screen.print @suite.summary
end