Testing Instrumentable Module Implementation in DevDocs
This test suite validates the Docs::Instrumentable module functionality in the DevDocs project, focusing on both extended and included implementation patterns. It ensures proper event subscription and instrumentation behavior across different usage scenarios.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
freecodecamp/devdocs
test/lib/docs/core/instrumentable_test.rb
require_relative '../../../test_helper'
require_relative '../../../../lib/docs'
class DocsInstrumentableTest < Minitest::Spec
let :extended_class do
Class.new.tap { |klass| klass.send :extend, Docs::Instrumentable }
end
let :included_class do
Class.new.tap { |klass| klass.send :include, Docs::Instrumentable }
end
it "works when extended" do
extended_class.subscribe('test') { @called = true }
extended_class.instrument 'test'
assert @called
end
it "works when included" do
instance = included_class.new
instance.subscribe('test') { @called = true }
instance.instrument 'test'
assert @called
end
end