require "test_helper"
require "rack/test"

module Judoscale
  describe "App Request Metrics" do
    include Rack::Test::Methods

    def app
      ::Rails.application
    end

    after {
      Reporter.instance.stop!
      MetricsStore.instance.clear
    }

    it "tracks request metrics for each request" do
      header "X-Request-Start", (Time.now.to_i - 10).to_s

      1.upto(3) { |i|
        get "/"

        _(last_response).must_be :ok?
        _(last_response.body).must_equal "Hello World"

        _(MetricsStore.instance.metrics.size).must_equal i
        _(MetricsStore.instance.metrics.last.identifier).must_equal :qt
      }
    end
  end
end

require "test_helper"
require "rack/test"

module Judoscale
  describe "App Request Metrics" do
    include Rack::Test::Methods

    def app
      # This refers to TestRailsApp created in test_helper.rb
      ::Rails.application
    end

    after {
      Reporter.instance.stop!
      MetricsStore.instance.clear
    }

    it "tracks request metrics for each request" do
      header "X-Request-Start", (Time.now.to_i - 10).to_s

      1.upto(3) { |i|
        get "/"

        _(last_response).must_be :ok?
        _(last_response.body).must_equal "Hello World"

        _(MetricsStore.instance.metrics.size).must_equal i
        _(MetricsStore.instance.metrics.last.identifier).must_equal :qt
      }
    end
  end
end

Add a note about where the ::Rails.application is defined
Add a note about where the ::Rails.application is defined

Co-authored-by: Adam McCrea <0e18f44c1fec03ec4083422cb58ba6a09ac4fb2a@adamlogic.com>