garethr/garethr-docker — pull request #32 by jumanjiman (2014-01-20 21:35:09+00:00)
Title: version (if defined) overrides ensure

clarify behavior when both version and ensure are specified

Before this commit:

* If version is generic (absent, latest, present), the catalog
compiles but fails to apply on host; rspec does not check this.

* If version is specified as 0.5.5 and ensure is specified,
the version overrides ensure; rspec is undefined.

After this commit:

* If version is generic, the catalog compiles; rspec confirms.

* Version always overrides ensure; rspec confirms.

New unit tests:

docker
with generic version
version absent
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "absent"
version latest
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "latest"
version present
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "present"
version overrides ensure
version absent and ensure absent
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "absent"
version latest and ensure absent
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "latest"
version present and ensure absent
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "present"
version 0.5.5 and ensure absent
behaves like a custom version
should contain Package[docker] with name => "lxc-docker-0.5.5" and ensure => "present"
version absent and ensure latest
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "absent"
version latest and ensure latest
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "latest"
version present and ensure latest
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "present"
version 0.5.5 and ensure latest
behaves like a custom version
should contain Package[docker] with name => "lxc-docker-0.5.5" and ensure => "present"
version absent and ensure present
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "absent"
version latest and ensure present
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "latest"
version present and ensure present
behaves like an ensure
should contain Package[docker] with name => "lxc-docker" and ensure => "present"
version 0.5.5 and ensure present
behaves like a custom version
should contain Package[docker] with name => "lxc-docker-0.5.5" and ensure => "present"

____

use shared examples for DRYer rspec

All unit tests pass before and after this commit.