Skip to content

Commit

Permalink
update tests for multiple hook calls
Browse files Browse the repository at this point in the history
thanks to MSP-Greg in #2690 (comment)
  • Loading branch information
doits committed Sep 6, 2021
1 parent c15a6b0 commit e0ec29e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/test_config.rb
Expand Up @@ -363,16 +363,31 @@ def test_silence_single_worker_warning_overwrite
def assert_run_hooks(hook_name, options = {})
configured_with = options[:configured_with] || hook_name

# test single, not an array
messages = []
conf = Puma::Configuration.new
conf.options[hook_name] = -> (a) {
messages << "#{hook_name} is called with #{a}"
}

conf.run_hooks hook_name, 'ARG', Puma::Events.strings
assert_equal messages, ["#{hook_name} is called with ARG"]

# test multiple
messages = []
conf = Puma::Configuration.new do |c|
c.send(configured_with) do |a|
messages << "#{hook_name} is called with #{a}"
messages << "#{hook_name} is called with #{a} one time"
end

c.send(configured_with) do |a|
messages << "#{hook_name} is called with #{a} a second time"
end
end
conf.load

conf.run_hooks hook_name, 'ARG', Puma::Events.strings
assert_equal messages, ["#{hook_name} is called with ARG"]
assert_equal messages, ["#{hook_name} is called with ARG one time", "#{hook_name} is called with ARG a second time"]
end
end

Expand Down

0 comments on commit e0ec29e

Please sign in to comment.