Thanks, Dewey! That got it working. Here is the first iteration, sort of copied from Dewey's example:before do@chef_run = ::ChefSpec::ChefRunner.new.converge 'x2go::default'endit 'should create a repo if it does not exists' doresource = @chef_run.find_resource("yum_repository", "x2go").to_hashexpect(resource).to include(:repo_name => 'x2go',:description => 'x2go (replaces NX)',:key => "http://download.opensuse.org/repositories/X11:/RemoteDesktop:/x2go/RHEL_6/repodata/repomd.xml.key",:action =">" [:add])endBecause I don't want to completely copy other people's code, here is my version:let(:chef_run) {ChefSpec::ChefRunner.new.converge 'x2go::default'}it 'should create a repo if it does not exists' doexpect(chef_run.find_resource('yum_repository','x2go').to_hash).to include(:repo_name => 'x2go',:description => 'x2go (replaces NX)',:key => "http://download.opensuse.org/repositories/X11:/RemoteDesktop:/x2go/RHEL_6/repodata/repomd.xml.key",:action =">" [:add])endOn Sep 28, 2013, at 11:23 PM, John Dewey < " target="_blank"> > wrote:I don't believe there is a matcher for it. However, you should be able to assert the LWRP syntax via #find_resource.We do similar with some keystone tests.
On Saturday, September 28, 2013 at 9:19 PM, Rilindo Foster wrote:
Is there a way to to write a chef spec assertion to see if the repo will be created? Here is my default.rb:
yum_repository "x2go" do
repo_name "x2go"
description "x2go (replaces NX)"
url "http://download.opensuse.org/repositories/X11:/RemoteDesktop:/x2go/RHEL_6/"
key "http://download.opensuse.org/repositories/X11:/RemoteDesktop:/x2go/RHEL_6/repodata/repomd.xml.key"
action :add
end
And here is my current chef spec at this point:
require 'chefspec'
describe 'x2go::default' do
let(:chef_run) {
ChefSpec::ChefRunner.new(:step_into => ['yum_repository']).converge 'x2go::default'
}
it 'should create a repo if it does not exists' do
chef_run.converge "x2go::default"
expect(chef_run).to create_file("x2go")
end
end
Doesn't work, which is probably because "create_file" is used with the "file" resource, not yum_repository LWRP.
It doesn't look like chef spec supports the yum_repository LWRP (or at least that I can see), so I am not sure what direction I should take from here. What approach should I take?
- Rilindo
Archive powered by MHonArc 2.6.16.