How to write chef spec for following cookbook?

130 views Asked by At

This is my recipe.rb:

require 'mixlib/shellout'
require "pry"

find = Mixlib::ShellOut.new("echo hostname -I")
find.run_command.stdout

What should I write it in my spec?

1

There are 1 answers

0
Chandan On BEST ANSWER

You don't need the echo command to get the output. you can directly run the command through mixlib/shellout and get then get the command output from stdout.

require 'mixlib/shellout'

find = Mixlib::ShellOut.new("hostname -I")
find.run_command.stdout