Class: Threat::Plugins::Rspec

Inherits:
Danger::Plugin
  • Object
show all
Defined in:
lib/threat/plugins/rspec.rb

Overview

This plugin runs RSpec and reports failing examples

Usage:

Dangerfile

“‘ruby danger.import_dangerfile(gem: ’threat’)

rspec.run! “‘

Constant Summary collapse

FAILING_SPECS_LOG =
'tmp/failing_specs.log'
SEPARATOR =
':'

Instance Method Summary collapse

Instance Method Details

#run!Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/threat/plugins/rspec.rb', line 21

def run!
  `bundle exec rspec -f failures --out #{FAILING_SPECS_LOG}`
  return if $CHILD_STATUS.exitstatus.zero?

  File.readlines(FAILING_SPECS_LOG).each do |line|
    file_path, line_number, example = line.split(SEPARATOR)

    failure("Example #{example.strip} failed at #{file_path.delete_prefix('./')}:#{line_number}")
  end
end