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: capture.rb
    path of file: ./repos/shoulda-matchers/spec/support/unit
    
    the code of the file until where you have to start completion: module Kernel
  # #capture, #silence_stream, and #silence_stderr were removed in rails 5.0,
  # but we keep it them here

  if method_defined?(:capture)
    undef_method :captur
    
  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
    old_stream.close
  end