You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: serve_spec.rb
    path of file: ./repos/chef/knife/spec/integration
    
    the code of the file until where you have to start completion: #
# Author:: John Keiser (<jkeiser@chef.io>)
# Copyright:: Copyright (c) Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under
    
  def with_knife_serve
    exception = nil
    t = Thread.new do

      knife("serve --chef-zero-port=8890")
    rescue
      exception = $!

    end
    begin
      Chef::Config.log_level = :debug
      Chef::Config.chef_server_url = "http://localhost:8890"
      Chef::Config.node_name = nil
      Chef::Config.client_key = nil
      api = Chef::ServerAPI.new
      yield api
    rescue
      if exception
        raise exception
      else
        raise
      end