automationchef-infradevopsinspec

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"

Solution

  • you just have to run the query before the describe block, strip it and then use expect on it. 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