mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Allow the negate formating for cmp (#6862)
* Allow the negate formating for cmp The 'cmp' matcher when used with a negation as 'should_not' does has a confusion formating when control fails: expected: 3 got: 3 This, because the 'format_actual' always pass 'false' to the 'format_expectation'. Thus the 'format_expectation' never reach the 'negate_str'. Signed-off-by: Pg <pg.developper.fr@gmail.com> * Linting Signed-off-by: Pg <pg.developper.fr@gmail.com> Co-authored-by: Vasundhara Jagdale <vjagdale@progress.com> --------- Signed-off-by: Pg <pg.developper.fr@gmail.com> Co-authored-by: Vasundhara Jagdale <vjagdale@progress.com>
This commit is contained in:
parent
cb807a4ac3
commit
f5fd9a75f7
1 changed files with 3 additions and 3 deletions
|
@ -299,9 +299,9 @@ RSpec::Matchers.define :cmp do |first_expected| # rubocop:disable Metrics/BlockL
|
|||
end
|
||||
end
|
||||
|
||||
def format_actual(actual)
|
||||
def format_actual(actual, negate = false)
|
||||
actual = "0%o" % actual if octal?(@expected) && !actual.nil?
|
||||
"\n%s\n got: %s\n\n(compared using `cmp` matcher)\n" % [format_expectation(false), actual]
|
||||
"\n%s\n got: %s\n\n(compared using `cmp` matcher)\n" % [format_expectation(negate), actual]
|
||||
end
|
||||
|
||||
def format_expectation(negate)
|
||||
|
@ -316,7 +316,7 @@ RSpec::Matchers.define :cmp do |first_expected| # rubocop:disable Metrics/BlockL
|
|||
end
|
||||
|
||||
failure_message_when_negated do |actual|
|
||||
format_actual actual
|
||||
format_actual actual, true
|
||||
end
|
||||
|
||||
description do
|
||||
|
|
Loading…
Reference in a new issue