2014-10-07 63 views
0

如何使用rspec的木偶碰定义?

define hello::world { 
    file { "/tmp/helloworld${name}": } 
} 

测试

require 'spec_helper' 

describe 'hello::world' do 
     let(:title) { '0' } 

     context 'test' do 
       let(:title) { '0' } 

       it do 
         should contain_file("/tmp/helloworld0") 
       end 
     end 
end 

at_exit { RSpec::Puppet::Coverage.report! } 

成果

[[email protected]] sudo rspec 
. 

Finished in 0.26947 seconds 
1 example, 0 failures 

Total resources: 2 
Touched resources: 1 
Resource coverage: 50.00% 
Untouched resources: 

    hello::world[0] 

多个源即123已经阅读并加入

it { should contain_define('hello::world[0]') }

it { should contain_class('hello::world[0]') }

,但问题仍然存在。

问题

如何使用rspec的木偶碰定义?

回答

2

按照documentation,你应该用下划线在资源类型替换冒号构造正确的匹配。

it { should contain_hello__world('0') }