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/stackneveroverflow/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/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,
    
    def test_finish_is_called_in_reverse_order
      events = []
      ret = [200, {}, []]
      app = lambda { |env| events << [app, :call]; ret }
      se1 = EventMiddleware.new events
      se2 = EventMiddleware.new events
      se3 = EventMiddleware.new events

      e = Events.new app, [se1, se2, se3]
      triple = e.call({})
      triple[2].each { |x| }
      triple[2].close

      groups = events.group_by { |x| x.last }
      assert_equal groups[:on_start].map(&:first), groups[:on_finish].map(&:first).reverse
      assert_equal groups[:on_commit].map(&:first), groups[:on_finish].map(&:first)
      assert_equal groups[:on_send].map(&:first), groups[:on_finish].map(&:first)
    end