Skip to content

Instantly share code, notes, and snippets.

@jeekl
Created May 13, 2013 15:46
Show Gist options
  • Save jeekl/5569294 to your computer and use it in GitHub Desktop.
Save jeekl/5569294 to your computer and use it in GitHub Desktop.
$ 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
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
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