In my .rb file, I am attempting to write a spec test against this line of code (I did not write this code):
execute "lvcreate -L #{node['ami_base']['opt']} -n opt vgpool"
In my _spec.rb file, my test looks like this for this particular section of code:
it 'executes lvcreate... -n opt vgpool' do
expect(chef_run).to run_execute("lvcreate -L #{node['ami_base']['opt']} -n opt vgpool")
end
When I attempt:
chef exec rspec....._spec.rb
I receive this error:
1) ami_base::lvm_drives executes lvcreate... -n opt vgpool
Failure/Error: expect(chef_run).to run_execute("lvcreate -L #{node['ami_base']['opt']} -n opt vgpool")
NameError:
undefined local variable or method `node' for #<RSpec::ExampleGroups::AmiBaseLvmDrives:0x0000000005752268>
# ./spec/unit/recipes/lvm_drives_spec.rb:33:in `block (2 levels) in <top (required)>'
I've written many tests against execute
and they've all been successful. Do I need to modify the spec helper file? I feel like it being a command line input and creating a volume that the command should be something other than run_execute, but i am coming up empty handed in a my searches for anything that works.