Class: Cadre::RSpec::QuickfixFormatter

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/cadre/rspec/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
16
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 12

def initialize(output)
  super(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.



17
18
19
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 17

def config
  @config
end

Instance Method Details

#dump_failures(*args) ⇒ Object



38
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 38

def dump_failures(*args); end

#dump_pending(*args) ⇒ Object



40
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 40

def dump_pending(*args); end

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



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

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(example) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 19

def example_failed(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



31
32
33
34
35
36
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 31

def example_pending(example)
  return unless config.include_pending?
  message = format_message example.execution_result[:pending_message]
  path    = format_caller example.location
  output.puts "#{path}: [PEND] #{message}" if path
end

#message(msg) ⇒ Object



42
# File 'lib/cadre/rspec/quickfix-formatter.rb', line 42

def message(msg); end