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: spec_events.rb
    path of file: ./repos/ferrocarril/mruby-gems/vendor/ruby/2.6.0/gems/rack-2.0.7/test
    
    the code of the file until where you have to start completion: require 'helper'
require 'rack/events'

module Rack
  class TestEvents < Rack::TestCase
    class EventMiddleware
      attr_reader :events

      def initialize events
        @events = events
      end

      def on_start req, res
        events << [self, __method__]
      end

      def on_commit req, res
        events << [self, __method__]
      end

      def on_send req, res
        events << [self, __method__]
      end

      def on_finish req, res
        events << [self, _
    
    def test_events_fire
      events = []
      ret = [200, {}, []]
      app = lambda { |env| events << [app, :call]; ret }
      se = EventMiddleware.new events
      e = Events.new app, [se]
      triple = e.call({})
      response_body = []
      triple[2].each { |x| response_body << x }
      triple[2].close
      triple[2] = response_body
      assert_equal ret, triple
      assert_equal [[se, :on_start],
                    [app, :call],
                    [se, :on_commit],
                    [se, :on_send],
                    [se, :on_finish],
      ], events
    end