简体   繁体   English

是否有从厨师检查 output 中删除 \n 的语法

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

When executing the below command:执行以下命令时:

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

Getting error as below, is there any error with the syntax, kindly advise.出现如下错误,语法是否有任何错误,请指教。

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

you just have to run the query before the describe block, strip it and then use expect on it.您只需要在describe块之前运行查询,将其剥离,然后在其上使用expect something like:就像是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM