ruby-sdk/test/instrumentation_test_helper.rb
Topher Bullock d2b6a33788 Internal Release 0.5.1
- Allow protocol version to be set at the server level through configuration instead of a class method, providing more flexibility in protocol version management [#43](https://github.com/Shopify/mcp-ruby/pull/43) @topherbullock

- Fixed instrumentation handling to ensure accurate timing information and proper error reporting [#42](https://github.com/Shopify/mcp-ruby/pull/42) @tobiasbales
  - Improved error handling and reporting in the server
  - Fixed timing information collection in instrumentation
  - Added proper error types for different failure scenarios
  - Enhanced test coverage for error cases

- [Allow protocol version to be set at the server level #43](https://github.com/Shopify/mcp-ruby/pull/43) @topherbullock
- [Fix instrumentation handling #42](https://github.com/Shopify/mcp-ruby/pull/42) @tobiasbales
2025-05-08 17:38:05 -04:00

24 lines
679 B
Ruby

# frozen_string_literal: true
module InstrumentationTestHelper
class Instrumentation
attr_reader :callback
attr_reader :data
def initialize
@callback = ->(data) { @data = data }
end
end
def instrumentation_helper
@instrumentation_helper ||= Instrumentation.new
end
def assert_instrumentation_data(expected_data)
data = instrumentation_helper.data.dup || {}
duration = data.delete(:duration)
assert_not_nil(duration, "Duration should always be set")
assert_operator(duration, :>=, 0, "Duration should be positive or zero")
assert_equal(expected_data, data, "Instrumentation data does not match expected data")
end
end