@@ -17,7 +17,7 @@ import {expect} from 'chai';
1717import { GitHub } from '../../src/github' ;
1818import { Ruby } from '../../src/strategies/ruby' ;
1919import * as sinon from 'sinon' ;
20- import { assertHasUpdate } from '../helpers' ;
20+ import { assertHasUpdate , buildGitHubFileRaw } from '../helpers' ;
2121import { buildMockConventionalCommit } from '../helpers' ;
2222import { TagName } from '../../src/util/tag-name' ;
2323import { Version } from '../../src/version' ;
@@ -26,6 +26,14 @@ import {VersionRB} from '../../src/updaters/ruby/version-rb';
2626import { GemfileLock } from '../../src/updaters/ruby/gemfile-lock' ;
2727import { PullRequestBody } from '../../src/util/pull-request-body' ;
2828
29+ const GEM_NAME = 'google-cloud-automl-gem' ;
30+
31+ const GEMFILE_CONTENTS = `
32+ Gem::Specification.new do |gem|
33+ gem.name = "${ GEM_NAME } "
34+ end
35+ ` ;
36+
2937const sandbox = sinon . createSandbox ( ) ;
3038
3139const COMMITS = [
@@ -46,7 +54,18 @@ describe('Ruby', () => {
4654 repo : 'ruby-test-repo' ,
4755 defaultBranch : 'main' ,
4856 } ) ;
57+
58+ const fileFilesStub = sandbox . stub ( github , 'findFilesByGlobAndRef' ) ;
59+ fileFilesStub
60+ . withArgs ( '*.gemspec' , 'main' )
61+ . resolves ( [ 'google-cloud-automl.gemspec' ] ) ;
62+
63+ const getFileContentsStub = sandbox . stub ( github , 'getFileContentsOnBranch' ) ;
64+ getFileContentsStub
65+ . withArgs ( 'google-cloud-automl.gemspec' , 'main' )
66+ . resolves ( buildGitHubFileRaw ( GEMFILE_CONTENTS ) ) ;
4967 } ) ;
68+
5069 afterEach ( ( ) => {
5170 sandbox . restore ( ) ;
5271 } ) ;
@@ -91,7 +110,11 @@ describe('Ruby', () => {
91110 github,
92111 component : 'google-cloud-automl' ,
93112 } ) ;
94- const latestRelease = undefined ;
113+ const latestRelease = {
114+ tag : new TagName ( Version . parse ( '0.123.4' ) , 'google-cloud-automl' ) ,
115+ sha : 'abc123' ,
116+ notes : 'some notes' ,
117+ } ;
95118 const release = await strategy . buildReleasePullRequest ( {
96119 commits : COMMITS ,
97120 latestRelease,
@@ -110,7 +133,20 @@ describe('Ruby', () => {
110133 'rbi/lib/google/cloud/automl/version.rbi' ,
111134 VersionRB
112135 ) ;
113- assertHasUpdate ( updates , 'Gemfile.lock' , GemfileLock ) ;
136+
137+ const gemfileLockUpdate = assertHasUpdate (
138+ updates ,
139+ 'Gemfile.lock' ,
140+ GemfileLock
141+ ) ;
142+
143+ // gemfile lock updater should be able to update content that includes the gem name from
144+ // the gemspec file
145+ expect (
146+ gemfileLockUpdate . updater . updateContent (
147+ `${ GEM_NAME } (${ latestRelease . tag . version } )`
148+ )
149+ ) . to . eql ( `${ GEM_NAME } (${ release ! . version } )` ) ;
114150 } ) ;
115151 it ( 'allows overriding version file' , async ( ) => {
116152 const strategy = new Ruby ( {
0 commit comments