Class: Holdify::Feedback
- Inherits:
-
Object
- Object
- Holdify::Feedback
- Defined in:
- lib/holdify/feedback.rb
Overview
Feedback report on failure
Defined Under Namespace
Instance Method Summary collapse
- #diff ⇒ Object
- #file_refs ⇒ Object
-
#initialize(hold, hold_ref, *args) ⇒ Feedback
constructor
A new instance of Feedback.
- #render ⇒ Object
Constructor Details
#initialize(hold, hold_ref, *args) ⇒ Feedback
Returns a new instance of Feedback.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/holdify/feedback.rb', line 10 def initialize(hold, hold_ref, *args) yaml_path = hold.store.path @yaml_lno = find_yaml_lno(hold, yaml_path) @yaml_ref = Holdify.relativize("#{yaml_path}:#{@yaml_lno}") @hold_ref = Holdify.relativize(hold_ref) test_ref = Holdify.relativize(hold.test_loc.to_s.sub(/:in .*$/, '')) @test_ref = test_ref unless @hold_ref == test_ref @expected, @actual, @message = *args # Extend features extend Color if Holdify.color return unless Holdify.git_diff @diff_yaml_headers = 2 # ----expected and +---actual (no sgr code) on 2 lines extend GitDiff # rubocop:disable Layout/EmptyLinesAfterModuleInclusion return unless Holdify.color @diff_yaml_headers = 1 # ---expected---actual (with sgr codes) on single line extend Color::GitDiff end |
Instance Method Details
#diff ⇒ Object
41 |
# File 'lib/holdify/feedback.rb', line 41 def diff = ["-#{@expected.inspect}", "+#{@actual.inspect}"] |
#file_refs ⇒ Object
35 36 37 38 39 |
# File 'lib/holdify/feedback.rb', line 35 def file_refs ["--- @stored --> #{@yaml_ref}", "+++ @tested --> #{@hold_ref}"].tap do |refs| refs << " --> #{@test_ref}" if @test_ref end end |
#render ⇒ Object
33 |
# File 'lib/holdify/feedback.rb', line 33 def render = [@message, *file_refs, *diff, ''].join("\n") |