是否有从 chef inspec 输出中删除 \n 的语法

Is there a syntax to remove the \n from the chef inspec output

执行以下命令时:

  describe sql.query("show pgaudit.log;") do
    its("output") { should match 'ERROR: unrecognized configuration parameter "pgaudit.log"' }
  end

报错如下,是否语法错误,请指教

 expected: "ERROR: unrecognized configuration parameter \"pgaudit.log\""
      got: "\nERROR:  unrecognized configuration parameter \"pgaudit.log\"\n"

您只需 运行 describe 块之前的查询,将其剥离,然后在其上使用 expect。类似于:

sql_query = sql.query("show pgaudit.log;")
describe sql_query do
  its("output") { 
    expect(sql_query.stdout.strip).to eq('ERROR: unrecognized configuration parameter "pgaudit.log"')
  }
end