Created
May 13, 2013 15:46
-
-
Save jeekl/5569294 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rspec . | |
.F | |
Failures: | |
1) foobar::package should install multiple versions of foobar | |
Failure/Error: expect(chef_run).to install_package 'foobar_15' | |
No package resource named 'foobar_15' with action :install found. | |
# ./spec/package_spec.rb:14 | |
Finished in 0.00221 seconds | |
2 examples, 1 failure | |
Failed examples: | |
rspec ./spec/package_spec.rb:12 # foobar::package should install multiple versions of foobar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg_ver = node['foobar']['package_version'] | |
if pkg_ver.kind_of? Array | |
pkg_ver.each do |ver| | |
package "foobar_#{ver}" | |
end | |
elsif pkg_ver.kind_of? String | |
package "foobar_#{pkg_ver}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'chefspec' | |
describe "foobar::package" do | |
chef_run = ChefSpec::ChefRunner.new.converge "foobar::package" | |
it "should install version 15" do | |
chef_run.node.foobar.package_version = '15' | |
expect(chef_run).to install_package "foobar_15" | |
end | |
it "should install multiple versions of foobar" do | |
chef_run.node.foobar.package_version = ['15', '16'] | |
expect(chef_run).to install_package 'foobar_15' | |
expect(chef_run).to install_package 'foobar_16' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment