Skip to content

Commit

Permalink
fix: try to find the ruby lock & ruby custom gemfile test
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Aug 19, 2020
1 parent 1376d3a commit dffbb75
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/plugins/rubygems/inspectors/gemfile.ts
Expand Up @@ -24,7 +24,7 @@ export async function gatherSpecs(root: string, target: string): Promise<Spec> {
// if the target is a Gemfile we treat is as the lockfile
const gemfileLock = await tryGetSpec(
root,
isGemfileLock ? target : path.join(dir, name + '.lock'),
isGemfileLock ? target : path.join(target + '.lock'),
);

if (gemfileLock) {
Expand Down
54 changes: 54 additions & 0 deletions test/acceptance/cli-test/cli-test.ruby.spec.ts
Expand Up @@ -77,6 +77,60 @@ export const RubyTests: AcceptanceTests = {
'depGraph looks fine',
);
},
'`test ruby-app-custom-names --file=123.gemfile --package-manager=rubygems`': (
params,
utils,
) => async (t) => {
utils.chdirWorkspaces();
await params.cli.test('ruby-app-custom-names', {
file: '123.gemfile',
packageManager: 'rubygems',
});

const req = params.server.popRequest();
t.equal(req.method, 'POST', 'makes POST request');
t.equal(
req.headers['x-snyk-cli-version'],
params.versionNumber,
'sends version number',
);
t.match(req.url, '/test-dep-graph', 'posts to correct url');

const depGraph = req.body.depGraph;
t.equal(depGraph.pkgManager.name, 'rubygems');
t.same(
depGraph.pkgs.map((p) => p.id).sort(),
[
'crass@1.0.4',
'lynx@0.4.0',
'mini_portile2@2.3.0',
'nokogiri@1.8.5',
'nokogumbo@1.5.0',
'ruby-app-custom-names@',
'sanitize@4.6.2',
'yard@0.8.0',
].sort(),
'depGraph looks fine',
);
},

'`test ruby-app-custom-names --file=gemfiles/Gemfile.rails-2.3.6 --package-manager=rubygems`': (
params,
utils,
) => async (t) => {
utils.chdirWorkspaces();
try {
await params.cli.test('ruby-app-custom-names', {
file: 'gemfiles/Gemfile.rails-2.3.6',
packageManager: 'rubygems',
});
} catch (e) {
t.match(
e.message,
'if this is a custom file name re-run with --file=path/to/custom.gemfile.lock --package-manager=rubygems',
);
}
},

'`test ruby-app-custom-names --file=gemfiles/Gemfile.rails-2.4.5.lock --package-manager=rubygems`': (
params,
Expand Down
@@ -0,0 +1,26 @@
GEM
remote: http://rubygems.org/
specs:
crass (1.0.4)
lynx (0.4.0)
mini_portile2 (2.3.0)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0)
nokogiri
sanitize (4.6.2)
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4)
yard (0.8.0)

PLATFORMS
ruby

DEPENDENCIES
lynx (= 0.4.0)
sanitize (= 4.6.2)
yard (= 0.8.0)

BUNDLED WITH
1.16.5
@@ -0,0 +1,26 @@
GEM
remote: http://rubygems.org/
specs:
crass (1.0.4)
lynx (0.4.0)
mini_portile2 (2.3.0)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0)
nokogiri
sanitize (4.6.2)
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4)
yard (0.8.0)

PLATFORMS
ruby

DEPENDENCIES
lynx (= 0.4.0)
sanitize (= 4.6.2)
yard (= 0.8.0)

BUNDLED WITH
1.16.5

0 comments on commit dffbb75

Please sign in to comment.