@@ -113,8 +113,14 @@ def template(args, server_context:)
113113 title : "Mock Prompt" ,
114114 description : "a mock prompt for testing" ,
115115 arguments : [
116- Prompt ::Argument . new ( name : "test_argument" , description : "Test argument" , required : true ) ,
116+ Prompt ::Argument . new (
117+ name : "test_argument" ,
118+ title : "Test argument title" ,
119+ description : "This is a test argument description" ,
120+ required : true ,
121+ ) ,
117122 ] ,
123+ meta : { foo : "bar" } ,
118124 ) do |args , server_context :|
119125 content = Content ::Text . new ( args [ "test_argument" ] + " user: #{ server_context [ :user_id ] } " )
120126
@@ -130,6 +136,10 @@ def template(args, server_context:)
130136 assert_equal "mock_prompt" , prompt . name_value
131137 assert_equal "a mock prompt for testing" , prompt . description
132138 assert_equal "test_argument" , prompt . arguments . first . name
139+ assert_equal "Test argument title" , prompt . arguments . first . title
140+ assert_equal "This is a test argument description" , prompt . arguments . first . description
141+ assert prompt . arguments . first . required
142+ assert_equal ( { foo : "bar" } , prompt . meta_value )
133143
134144 expected = {
135145 description : "Hello, world!" ,
@@ -142,5 +152,43 @@ def template(args, server_context:)
142152 result = prompt . template ( { "test_argument" => "Hello, friend!" } , server_context : { user_id : 123 } )
143153 assert_equal expected , result . to_h
144154 end
155+
156+ test "#to_h returns a hash with name, title, description, arguments, and meta" do
157+ class FullPrompt < Prompt
158+ prompt_name "test_prompt"
159+ description "Test prompt description"
160+ title "Test Prompt title"
161+ arguments [
162+ Prompt ::Argument . new ( name : "test_argument" , description : "Test argument" , required : true ) ,
163+ ]
164+ meta ( { test : "meta" } )
165+ end
166+
167+ expected = {
168+ name : "test_prompt" ,
169+ title : "Test Prompt title" ,
170+ description : "Test prompt description" ,
171+ arguments : [
172+ { name : "test_argument" , description : "Test argument" , required : true } ,
173+ ] ,
174+ _meta : { test : "meta" } ,
175+ }
176+
177+ assert_equal expected , FullPrompt . to_h
178+ end
179+
180+ test "#to_h handles nil arguments value" do
181+ class NoArgumentsPrompt < Prompt
182+ description "No arguments prompt"
183+ end
184+ prompt = NoArgumentsPrompt
185+
186+ expected = {
187+ name : "no_arguments_prompt" ,
188+ description : "No arguments prompt" ,
189+ }
190+
191+ assert_equal expected , prompt . to_h
192+ end
145193 end
146194end
0 commit comments