Sha256: 36d71770d2290cf7c71b55790876bccd8b4f04cbe260d8f9f878ec37ee71b440

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

Use the `cmp` matcher compare two values, such as comparing strings to numbers, comparing a single value to an array of values, comparing an array of strings to a regular expression, improving the printing of octal values, and comparing while ignoring case sensitivity.

Compare a single value to an array:

    describe some_resource do
      its('users') { should cmp 'root' }
      its('users') { should cmp ['root'] }
    end

Compare strings and regular expressions:

    describe some_resource do
      its('setting') { should cmp /raw/i }
    end

Compare strings and numbers:

    describe some_resource do
      its('setting') { should eq '2' }
    end

vs:

    describe some_resource do
      its('setting') { should cmp '2' }
      its('setting') { should cmp 2 }
    end

Ignoring case sensitivity:

    describe some_resource do
      its('setting') { should cmp 'raw' }
      its('setting') { should cmp 'RAW' }
    end

Printing octal values:

    describe some_resource('/proc/cpuinfo') do
      its('mode') { should cmp '0345' }
    end

    expected: 0345
    got: 0444

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inspec-2.1.81 docs/shared/matcher_cmp.md.erb
inspec-2.1.21 docs/shared/matcher_cmp.md.erb
inspec-2.1.10 docs/shared/matcher_cmp.md.erb
inspec-2.0.32 docs/shared/matcher_cmp.md.erb
inspec-2.0.17 docs/shared/matcher_cmp.md.erb
inspec-1.51.15 docs/shared/matcher_cmp.md.erb