Skip to content

Commit 5daff4f

Browse files
committed
test: add enforcement test for Streaming module inclusion
Ensures all classifiers (Bayes, LSI, KNN, LogisticRegression, TFIDF) include the Streaming module and respond to required methods. This catches missing implementations when new classifiers are added.
1 parent b7a6e91 commit 5daff4f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

test/streaming/streaming_test.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,35 @@ def test_delete_checkpoint_requires_storage
335335
end
336336
end
337337
end
338+
339+
class StreamingEnforcementTest < Minitest::Test
340+
CLASSIFIERS = [
341+
Classifier::Bayes,
342+
Classifier::LSI,
343+
Classifier::KNN,
344+
Classifier::LogisticRegression,
345+
Classifier::TFIDF
346+
].freeze
347+
348+
STREAMING_METHODS = %i[
349+
train_from_stream
350+
train_batch
351+
save_checkpoint
352+
list_checkpoints
353+
delete_checkpoint
354+
].freeze
355+
356+
CLASSIFIERS.each do |klass|
357+
define_method("test_#{klass.name.split('::').last.downcase}_includes_streaming") do
358+
assert klass.include?(Classifier::Streaming),
359+
"#{klass} must include Classifier::Streaming"
360+
end
361+
362+
STREAMING_METHODS.each do |method|
363+
define_method("test_#{klass.name.split('::').last.downcase}_responds_to_#{method}") do
364+
assert klass.method_defined?(method) || klass.private_method_defined?(method),
365+
"#{klass} must respond to #{method}"
366+
end
367+
end
368+
end
369+
end

0 commit comments

Comments
 (0)