d917896f45
We recently let a few very easy to avoid warnings get merged. The root cause is that locally the test suite doesn't run in verbose mode unless you explictly pass `-w`. On CI warnings are enabled, but there is no reason to look at the build output unless something is failing. And even if one wanted to do that, that would be particularly work intensive since warnings may be specific to a Ruby version etc. Because of this I believe we should: - Always run the test suite with warnings enabled. - Raise an error if a warning is unexpected. We've been using this pattern for a long time at Shopify both in private and public repositories.
84 lines
1.9 KiB
Ruby
84 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "active_support/testing/strict_warnings"
|
|
require "active_support"
|
|
require "active_support/testing/autorun"
|
|
require "rails/configuration"
|
|
require "active_support/test_case"
|
|
require "minitest/mock"
|
|
|
|
module Rails
|
|
module Configuration
|
|
class MiddlewareStackProxyTest < ActiveSupport::TestCase
|
|
def setup
|
|
@stack = MiddlewareStackProxy.new
|
|
end
|
|
|
|
def test_playback_insert_before
|
|
@stack.insert_before :foo
|
|
assert_playback :insert_before, :foo
|
|
end
|
|
|
|
def test_playback_insert
|
|
@stack.insert :foo
|
|
assert_playback :insert_before, :foo
|
|
end
|
|
|
|
def test_playback_insert_after
|
|
@stack.insert_after :foo
|
|
assert_playback :insert_after, :foo
|
|
end
|
|
|
|
def test_playback_swap
|
|
@stack.swap :foo
|
|
assert_playback :swap, :foo
|
|
end
|
|
|
|
def test_playback_use
|
|
@stack.use :foo
|
|
assert_playback :use, :foo
|
|
end
|
|
|
|
def test_playback_delete
|
|
@stack.delete :foo
|
|
assert_playback :delete, :foo
|
|
end
|
|
|
|
def test_playback_move_before
|
|
@stack.move_before :foo
|
|
assert_playback :move_before, :foo
|
|
end
|
|
|
|
def test_playback_move
|
|
@stack.move :foo
|
|
assert_playback :move_before, :foo
|
|
end
|
|
|
|
def test_playback_move_after
|
|
@stack.move_after :foo
|
|
assert_playback :move_after, :foo
|
|
end
|
|
|
|
def test_order
|
|
@stack.swap :foo
|
|
@stack.delete :foo
|
|
|
|
mock = Minitest::Mock.new
|
|
mock.expect :swap, nil, [:foo]
|
|
mock.expect :delete, nil, [:foo]
|
|
|
|
@stack.merge_into mock
|
|
mock.verify
|
|
end
|
|
|
|
private
|
|
def assert_playback(msg_name, args)
|
|
mock = Minitest::Mock.new
|
|
mock.expect msg_name, nil, [args]
|
|
@stack.merge_into(mock)
|
|
mock.verify
|
|
end
|
|
end
|
|
end
|
|
end
|