Class: Cadre::RSpec3::QuickfixFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cadre/rspec3/quickfix-formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ QuickfixFormatter

TODO: vim-side function for printing progress (if that's even possible)


12
13
14
15
# File 'lib/cadre/rspec3/quickfix-formatter.rb', line 12

def initialize(output)
  @config = Config.new(Valise, "quickfix")
  @output = File::open(@config.output_path, "w")
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


16
17
18
# File 'lib/cadre/rspec3/quickfix-formatter.rb', line 16

def config
  @config
end

#outputObject (readonly)

Returns the value of attribute output


16
17
18
# File 'lib/cadre/rspec3/quickfix-formatter.rb', line 16

def output
  @output
end

Instance Method Details

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object


43
44
45
46
47
48
# File 'lib/cadre/rspec3/quickfix-formatter.rb', line 43

def dump_summary(duration, example_count, failure_count, pending_count)
  @duration = duration
  @example_count = example_count
  @failure_count = failure_count
  @pending_count = pending_count
end

#example_failed(notification) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cadre/rspec3/quickfix-formatter.rb', line 20

def example_failed(notification)
  example = notification.example

  exception = example.execution_result.exception
  paths = exception.backtrace.map do |frame|
    format_caller frame
  end.compact
  paths = paths[0..config.backtrace_limit]
  message = "#{example.full_description}: #{format_message exception.message}"
  paths.each do |path|
    output.puts "#{path}: [FAIL] #{message}"
  end
end

#example_pending(example) ⇒ Object


34
35
36
37
38
39
40
41
# File 'lib/cadre/rspec3/quickfix-formatter.rb', line 34

def example_pending(example)
  return unless config.include_pending?
  example = notification.example

  message = format_message example.execution_result[:pending_message]
  path    = format_caller example.location
  output.puts "#{path}: [PEND] #{message}" if path
end