Я пишу тесты Chefspec, и у меня есть код ниже
recipe
execute 'stop Server' do
user '123'
group 'ad'
live_stream true
command "/udd001/app/WebSphere/AppServer/profiles/AppSrv01/bin/stopServer.sh $server -username wasserver -password #{password}"
only_if { ::File.exist?('/mypath/'+variable[:myserver) }
spec
require 'spec_helper'
describe 'cookbook::myserver' do
before do
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with('/mypath/'+variable[:appserver_profile]).and_return(true)
end
context 'When all attributes are default, on Ubuntu 16.04' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it 'stop Server' do
expect(chef_run).to run_execute('myserver').with(
user: '123',
group: 'ad',
live_stream: true)
end
end
end
он терпит неудачу с локальной переменной "переменная" не определена