class RspecKeyValue::Formatter

A simple Rspec formatter which prints the results in the form R:group.sub_group.example_name where R is -1 for PENDING, 0 for FAILED and 1 for PASS result

Public Class Methods

new(output) click to toggle source
Calls superclass method
# File lib/rspec_key_value/formatter.rb, line 19
def initialize(output)
  super(output)
  @groups = []
end

Public Instance Methods

dump_failures(notification) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 46
def dump_failures(notification); end
dump_pending(notification) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 48
def dump_pending(notification); end
dump_summary(summary) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 44
def dump_summary(summary); end
example_failed(failure) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 40
def example_failed(failure)
  output.puts example_line(0, failure)
end
example_group_finished(_notification) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 28
def example_group_finished(_notification)
  @groups.pop
end
example_group_started(notification) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 24
def example_group_started(notification)
  @groups.push clean_string(notification.group.description)
end
example_passed(passed) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 32
def example_passed(passed)
  output.puts example_line(1, passed)
end
example_pending(pending) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 36
def example_pending(pending)
  output.puts example_line(-1, pending)
end
seed(notification) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 50
def seed(notification); end

Private Instance Methods

clean_string(text) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 54
def clean_string(text)
  text.strip.downcase.gsub(/[^\w.]+/, '_')
end
current_group(gs = nil) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 58
def current_group(gs = nil)
  gs = @groups unless gs
  clean_string gs.join('.')
end
example_line(result, notification) click to toggle source
# File lib/rspec_key_value/formatter.rb, line 63
def example_line(result, notification)
  description = clean_string(notification.example.description)
  "#{result}:#{current_group}.#{description}"
end