Docs: describe custom matcher cmp on version strings (#2214)

* Docs update to describe using cmp for version matching on packages

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* Add 'and' and force Travis to re-run checks

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2017-10-05 13:18:12 -04:00 committed by Adam Leff
parent 19ecd6eeeb
commit 90fc6affd2
2 changed files with 13 additions and 0 deletions

View file

@ -68,6 +68,13 @@ end
its('log_format') { should cmp 'RAW' }
end
```
* Recognize versions embedded in strings
```ruby
describe package(curl) do
its('version') { should cmp > '7.35.0-1ubuntu2.10' }
end
```
* Compare arrays with only one entry to a value

View file

@ -111,3 +111,9 @@ The `be_installed` matcher tests if the named package is installed on the system
The `version` matcher tests if the named package version is on the system:
its('version') { should eq '1.2.3' }
You can also use the `cmp OPERATOR` matcher to perform comparisions using the version attribute:
its('version') { should cmp >= '7.35.0-1ubuntu3.10' }
`cmp` understands version numbers using Gem::Version, and can use the operators `==, <, <=, >=, and >`. It will compare versions by each segment, not as a string - so '7.4' is smaller than '7.30', for example.