2014-10-07 61 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') }