mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Merge pull request #1211 from chef/ap/cmp-inspect
Show actual value for cmp octal comparisons in string to match expected
This commit is contained in:
commit
ac24bbaa3d
3 changed files with 5 additions and 2 deletions
|
@ -305,12 +305,12 @@ RSpec::Matchers.define :cmp do |first_expected|
|
|||
end
|
||||
|
||||
failure_message do |actual|
|
||||
actual = '0' + actual.to_s(8) if octal?(@expected)
|
||||
actual = ('0' + actual.to_s(8)).inspect if octal?(@expected)
|
||||
"\n" + format_expectation(false) + "\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
|
||||
end
|
||||
|
||||
failure_message_when_negated do |actual|
|
||||
actual = '0' + actual.to_s(8) if octal?(@expected)
|
||||
actual = ('0' + actual.to_s(8)).inspect if octal?(@expected)
|
||||
"\n" + format_expectation(true) + "\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
|
||||
end
|
||||
|
||||
|
|
|
@ -176,6 +176,8 @@ Test Summary: \e[32m2 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[
|
|||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ 7 should cmp >= 9\n"
|
||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ 7 should not cmp == /^\\d$/\n"
|
||||
out.stdout.force_encoding(Encoding::UTF_8).must_include "✔ 7 should cmp == \"7\""
|
||||
out.stdout.force_encoding(Encoding::UTF_8).must_include " expected: \"01147\"
|
||||
got: \"01777\"\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ end
|
|||
describe file('/tmp') do
|
||||
it { should_not be_directory }
|
||||
it { should be_directory }
|
||||
its('mode') { should cmp '01147' }
|
||||
end
|
||||
|
||||
# control, first and second fail, third passes
|
||||
|
|
Loading…
Add table
Reference in a new issue