# Revision history [back]

The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here.

You could do this (note that you must use the UK spelling for catalogue, which is especially surprising):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
}
it do
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
end


However it is far simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

You could do this (note that you must use the UK spelling for catalogue, which is especially surprising):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
}
it do
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
end


However it is far simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

You If you really need to use this feature, you could do this (note that (note: you must use the UK spelling for catalogue, which is especially surprising):):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
}
it do
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
end


However it is far simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

If you really need to use this feature, you could do this (note: you must use the UK spelling for catalogue):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
}
it do
{
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
end
}


However it is simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

If you really need to use this feature, you could do this (note: you must use the UK spelling for catalogue):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
}
it {
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
}


However it is simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


If you need the functionality in the verify_contents method, I'd have a look at other ways of achieving the same result, e.g. here.

The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

If you really need to use this feature, you could do this (note: you must use the UK spelling for catalogue):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
}
it {
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
}


However it is simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


If you need the functionality in the verify_contents method, I'd have a look at other ways of achieving the same result, e.g. here.

The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

If you really need to use this feature, you could do this (note: you must use the UK spelling for catalogue):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
}


However it is simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


If you need the functionality in the verify_contents method, I'd have a look at other ways of achieving the same result, e.g. here.

The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature, and certainly not feature here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

If you really need to use this feature, you could do this (note: you must use the UK spelling for catalogue):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
}


However it is simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


The method verify_contents is an undocumented feature provided by the puppetlabs_spec_helper gem, and my recommendation would be not to use this feature here.

You can see some example code that uses verify_contents here and you can see the method's source code here.

If you really need to use this feature, you could do this (note: you must use the UK spelling for catalogue):

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
verify_contents(catalogue, '/etc/resolv.conf', ['search server.com'])
}


However it is simpler just to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
'content' => "search server.com\n",
)
}


As you have mentioned in the comments it's also possible to do this:

it {
is_expected.to contain_file('/etc/resolv.conf').with(
'ensure'  => 'present',
'mode'    => '0640',
'group'   => 'root',
'owner'   => 'root',
)
content = catalogue.resource('file', '/etc/resolv.conf').send(:parameters)[:content]
expect(content).to match 'search server.com'
}