Merge pull request #1204 from chef/ap/cmp-desc

cmp code_desc missing operation and expected valid
This commit is contained in:
Dominik Richter 2016-10-10 06:12:37 -07:00 committed by GitHub
commit 6e1ffb4890
3 changed files with 17 additions and 0 deletions

View file

@ -313,6 +313,10 @@ RSpec::Matchers.define :cmp do |first_expected|
actual = '0' + actual.to_s(8) if octal?(@expected)
"\n" + format_expectation(true) + "\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
end
description do
"cmp #{@operation} #{@expected.inspect}"
end
end
# user resource matcher for serverspec compatibility

View file

@ -173,6 +173,9 @@ 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 "✖ should not be directory\n"
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ undefined method `should_nota'"
out.stdout.force_encoding(Encoding::UTF_8).must_include "✖ should not be directory\n expected `File /tmp.directory?` to return false, got true\e[0m"
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\""
end
end

View file

@ -30,3 +30,13 @@ describe file('/tmp') do
it { should_not be_directory }
it { should be_directory }
end
# control, first and second fail, third passes
control 'cmp-1.0' do
title 'Using the cmp matcher for numbers'
describe 7 do
it { should cmp >= 9 }
it { should_not cmp /^\d$/ }
it { should cmp == '7' }
end
end