@@ -29,13 +29,13 @@ def handle_request(request); end
29
29
setup do
30
30
configuration = MCP ::Configuration . new
31
31
configuration . instrumentation_callback = instrumentation_helper . callback
32
-
32
+
33
33
@server = Server . new (
34
34
name : "test_server" ,
35
35
version : "1.0.0" ,
36
- configuration : configuration
36
+ configuration : configuration ,
37
37
)
38
-
38
+
39
39
@mock_transport = MockTransport . new ( @server )
40
40
@server . transport = @mock_transport
41
41
end
@@ -69,7 +69,7 @@ def handle_request(request); end
69
69
70
70
test "notification methods work without transport" do
71
71
server_without_transport = Server . new ( name : "test_server" )
72
-
72
+
73
73
# Should not raise any errors
74
74
assert_nothing_raised do
75
75
server_without_transport . notify_tools_list_changed
@@ -85,16 +85,16 @@ def send_notification(method, params = nil)
85
85
raise StandardError , "Transport error"
86
86
end
87
87
end . new ( @server )
88
-
88
+
89
89
@server . transport = error_transport
90
-
90
+
91
91
# Mock the exception reporter
92
92
expected_contexts = [
93
93
{ notification : "tools_list_changed" } ,
94
94
{ notification : "prompts_list_changed" } ,
95
- { notification : "resources_list_changed" }
95
+ { notification : "resources_list_changed" } ,
96
96
]
97
-
97
+
98
98
call_count = 0
99
99
@server . configuration . exception_reporter . expects ( :call ) . times ( 3 ) . with do |exception , context |
100
100
assert_kind_of StandardError , exception
@@ -103,14 +103,14 @@ def send_notification(method, params = nil)
103
103
call_count += 1
104
104
true
105
105
end
106
-
106
+
107
107
# Should not raise errors to the caller
108
108
assert_nothing_raised do
109
109
@server . notify_tools_list_changed
110
110
@server . notify_prompts_list_changed
111
111
@server . notify_resources_list_changed
112
112
end
113
-
113
+
114
114
assert_equal 3 , call_count
115
115
end
116
116
@@ -120,7 +120,7 @@ def send_notification(method, params = nil)
120
120
@server . notify_resources_list_changed
121
121
122
122
assert_equal 3 , @mock_transport . notifications . size
123
-
123
+
124
124
notifications = @mock_transport . notifications
125
125
assert_equal Methods ::NOTIFICATIONS_TOOLS_LIST_CHANGED , notifications [ 0 ] [ :method ]
126
126
assert_equal Methods ::NOTIFICATIONS_PROMPTS_LIST_CHANGED , notifications [ 1 ] [ :method ]
@@ -133,4 +133,4 @@ def send_notification(method, params = nil)
133
133
assert_equal "notifications/resources/list_changed" , Methods ::NOTIFICATIONS_RESOURCES_LIST_CHANGED
134
134
end
135
135
end
136
- end
136
+ end
0 commit comments