From 8e019b4af9f67d95ddd6ac39fc736da9a67281ea Mon Sep 17 00:00:00 2001 From: Keita Urashima Date: Mon, 6 Apr 2026 09:11:29 +0900 Subject: [PATCH 1/2] Increment Minitest assertion count in assert_schema_conform methods assert_request_schema_confirm and assert_response_schema_confirm did not call Minitest's assert, so they were not counted as assertions. This caused Minitest to emit "Test is missing assertions" warnings when these were the only assertions in a test. Call `assert true` after successful validation to increment the assertion counter. The call is guarded by `respond_to?(:assertions)` so it is a no-op in non-Minitest environments (e.g. RSpec). Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/committee/test/methods.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/committee/test/methods.rb b/lib/committee/test/methods.rb index 9b06fc98..67948270 100644 --- a/lib/committee/test/methods.rb +++ b/lib/committee/test/methods.rb @@ -23,6 +23,8 @@ def assert_request_schema_confirm(except: {}) schema_validator.request_validate(request_object) end end + + increment_assertion_count end def assert_response_schema_confirm(expected_status = nil) @@ -46,6 +48,8 @@ def assert_response_schema_confirm(expected_status = nil) end schema_validator.response_validate(status, headers, [body], true) if validate_response?(status) + + increment_assertion_count end def committee_options @@ -90,6 +94,10 @@ def old_behavior private + def increment_assertion_count + assert true if respond_to?(:assertions) + end + # Temporarily adds dummy values for excepted parameters during validation # @see ExceptParameter def with_except_params(except) From 78e643cfc2d40749a304a015a6cb9cb9c48b7d33 Mon Sep 17 00:00:00 2001 From: Keita Urashima Date: Sat, 11 Apr 2026 12:24:50 +0900 Subject: [PATCH 2/2] Address review feedback: add comment and regression tests - Explain why increment_assertion_count exists so future readers understand the Minitest assertion counting nuance. - Add tests that verify assert_request_schema_confirm and assert_response_schema_confirm each bump the Minitest assertion count on success, guarding against regression. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/committee/test/methods.rb | 3 +++ test/test/methods_test.rb | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/committee/test/methods.rb b/lib/committee/test/methods.rb index 67948270..49c9a46e 100644 --- a/lib/committee/test/methods.rb +++ b/lib/committee/test/methods.rb @@ -94,6 +94,9 @@ def old_behavior private + # assert_*_schema_confirm signal failure by raising, not via `assert`, + # so Minitest would report "Test is missing assertions" on success. + # Bump the counter explicitly; no-op outside Minitest (e.g. RSpec). def increment_assertion_count assert true if respond_to?(:assertions) end diff --git a/test/test/methods_test.rb b/test/test/methods_test.rb index eebc4f32..a9b000d1 100644 --- a/test/test/methods_test.rb +++ b/test/test/methods_test.rb @@ -151,6 +151,14 @@ def response_data assert_request_schema_confirm end + it "increments the Minitest assertion count on success" do + @app = new_rack_app + get "/characters" + before_count = assertions + assert_request_schema_confirm + assert_equal before_count + 1, assertions + end + it "not exist required" do @app = new_rack_app get "/validate", { "query_string" => "query", "query_integer_list" => [1, 2] } @@ -397,6 +405,14 @@ def response_data assert_response_schema_confirm(200) end + it "increments the Minitest assertion count on success" do + @app = new_rack_app(JSON.generate(@correct_response)) + get "/characters" + before_count = assertions + assert_response_schema_confirm(200) + assert_equal before_count + 1, assertions + end + it "detects an invalid response Content-Type" do @app = new_rack_app(JSON.generate([@correct_response]), {}) get "/characters"