Class: RSpec::Undefined::Reporters::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/undefined/reporters/markdown.rb

Constant Summary collapse

HEADERS =
%w[No. kind matcher category description expected actual matched location].freeze

Instance Method Summary collapse

Constructor Details

#initialize(path, stderr: $stderr) ⇒ Markdown

Returns a new instance of Markdown.



11
12
13
14
# File 'lib/rspec/undefined/reporters/markdown.rb', line 11

def initialize(path, stderr: $stderr)
  @path = path
  @stderr = stderr
end

Instance Method Details

#writeObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rspec/undefined/reporters/markdown.rb', line 16

def write
  entries = RSpec::Undefined.registry.all
  tmp_path = "#{@path}.tmp.#{Process.pid}"
  begin
    write_body(tmp_path, entries)
    File.rename(tmp_path, @path)
  rescue SystemCallError, IOError => ex
    File.delete(tmp_path) if File.exist?(tmp_path)
    @stderr.puts "[rspec-undefined] failed to write #{@path}: #{ex.message}"
  end
end