require 'minitest/autorun'

require 'request_store'

class MiddlewareTest < Minitest::Test
  def setup
    @app = RackApp.new
    @middleware = RequestStore::Middleware.new(@app)
  end

  def test_middleware_resets_store
    2.times { @middleware.call({}) }

    assert_equal 1, @app.last_value
    assert_equal({}, RequestStore.store)
  end

  def test_middleware_resets_store_on_error
    e = assert_raises RuntimeError do
      @middleware.call({:error => true})
    end

    assert_equal 'FAIL', e.message
    assert_equal({}, RequestStore.store)
  end
end

require 'minitest/test'
require 'minitest/autorun'

require 'request_store'

class MiddlewareTest < Minitest::Test
  def setup
    @app = RackApp.new
    @middleware = RequestStore::Middleware.new(@app)
  end

  def test_middleware_resets_store
    2.times { @middleware.call({}) }

    assert_equal 1, @app.last_value
    assert_equal({}, RequestStore.store)
  end

  def test_middleware_resets_store_on_error
    e = assert_raises RuntimeError do
      @middleware.call({:error => true})
    end

    assert_equal 'FAIL', e.message
    assert_equal({}, RequestStore.store)
  end
end

Fix minitest warning with an additional 'require'.
Fix minitest warning with an additional 'require'.

Running the test suite out-of-the-box throws a warning, although the
test suite still passes:

  $ rake
  ...
  Warning: you should require 'minitest/autorun' instead.
  Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
  ...
  $ echo $?
  0

If we add an additional "require" to test/middleware_test.rb,

  require 'minitest/test'

the warning goes away and the test suite still passes:

  $ rake
  ...
  # Running:

  ...........

  Finished in 0.001800s, 6110.1165 runs/s, 11109.3028 assertions/s.

  11 runs, 20 assertions, 0 failures, 0 errors, 0 skips
