describe CLIHelper do
  describe ".shellout!" do
    it "returns stdout when the command outputs to stdout" do
      expect(CLIHelper.shellout!("echo good").strip).to eq "good"
    end

    it "raises StandardError when the command outputs to stderr " do
      expect do
        CLIHelper.shellout!('>&2 echo "something went wrong!"')
      end.to raise_error(StandardError)
    end

    it "returns stderr when the command outputs to stderr and fail_on_std_err is false" do
      stderr = CLIHelper.shellout!("cat nosuchfile && echo done", false)
      expect(stderr.strip).to eq "cat: nosuchfile: No such file or directory"
    end
  end
end
