@@ -517,6 +517,54 @@ describe("Registry Modules", () => {
517517 expect ( versions [ 2 ] . number ) . toBe ( "7.0.2" ) ;
518518 expect ( versions [ 2 ] . status ) . toBe ( "" ) ;
519519 } ) ;
520+
521+ it ( "should fetch version-specific dependencies via v2 API" , async ( ) => {
522+ const client = new Client ( ) ;
523+ const mockResponse = {
524+ name : "rails" ,
525+ version : "5.0.0" ,
526+ description : "Ruby on Rails is a web-application framework" ,
527+ licenses : [ "MIT" ] ,
528+ dependencies : {
529+ runtime : [
530+ { name : "actioncable" , requirements : "= 5.0.0" } ,
531+ { name : "activesupport" , requirements : "= 5.0.0" } ,
532+ ] ,
533+ development : [ { name : "bundler" , requirements : ">= 1.15.0" } ] ,
534+ } ,
535+ } ;
536+
537+ const spy = vi . spyOn ( client , "getJSON" ) . mockResolvedValueOnce ( mockResponse ) ;
538+
539+ const registry = create ( "gem" , undefined , client ) ;
540+ const deps = await registry . fetchDependencies ( "rails" , "5.0.0" ) ;
541+
542+ expect ( spy ) . toHaveBeenCalledWith (
543+ expect . stringContaining ( "/api/v2/rubygems/rails/versions/5.0.0.json" ) ,
544+ undefined ,
545+ ) ;
546+
547+ expect ( deps ) . toHaveLength ( 3 ) ;
548+ expect ( deps [ 0 ] . name ) . toBe ( "actioncable" ) ;
549+ expect ( deps [ 0 ] . requirements ) . toBe ( "= 5.0.0" ) ;
550+ expect ( deps [ 0 ] . scope ) . toBe ( "runtime" ) ;
551+ expect ( deps [ 1 ] . name ) . toBe ( "activesupport" ) ;
552+ expect ( deps [ 1 ] . scope ) . toBe ( "runtime" ) ;
553+ expect ( deps [ 2 ] . name ) . toBe ( "bundler" ) ;
554+ expect ( deps [ 2 ] . scope ) . toBe ( "development" ) ;
555+ } ) ;
556+
557+ it ( "should throw NotFoundError for missing gem version" , async ( ) => {
558+ const client = new Client ( ) ;
559+
560+ vi . spyOn ( client , "getJSON" ) . mockRejectedValueOnce (
561+ new HTTPError ( 404 , "https://mock/not-found" , "Not Found" ) ,
562+ ) ;
563+
564+ const registry = create ( "gem" , undefined , client ) ;
565+
566+ await expect ( registry . fetchDependencies ( "rails" , "0.0.0" ) ) . rejects . toThrow ( NotFoundError ) ;
567+ } ) ;
520568 } ) ;
521569
522570 describe ( "packagist registry" , ( ) => {
0 commit comments