Skip to content

Commit f8d1c47

Browse files
committed
packagedcode: add gemspec version constant coverage
Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
1 parent c77ae2f commit f8d1c47

File tree

7 files changed

+95
-43
lines changed

7 files changed

+95
-43
lines changed

tests/packagedcode/data/rubygems/gemspec/github.gemspec.expected.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "gem",
44
"namespace": null,
55
"name": "github",
6-
"version": "GitHub::VERSION",
6+
"version": null,
77
"qualifiers": {},
88
"subpath": null,
99
"primary_language": "Ruby",
@@ -48,7 +48,7 @@
4848
],
4949
"keywords": [],
5050
"homepage_url": "https://github.com/defunkt/github-gem",
51-
"download_url": "https://rubygems.org/downloads/github-GitHub::VERSION.gem",
51+
"download_url": null,
5252
"size": null,
5353
"sha1": null,
5454
"md5": null,
@@ -162,10 +162,10 @@
162162
"extra_data": {}
163163
}
164164
],
165-
"repository_homepage_url": "https://rubygems.org/gems/github/versions/GitHub::VERSION",
166-
"repository_download_url": "https://rubygems.org/downloads/github-GitHub::VERSION.gem",
167-
"api_data_url": "https://rubygems.org/api/v2/rubygems/github/versions/GitHub::VERSION.json",
165+
"repository_homepage_url": "https://rubygems.org/gems/github",
166+
"repository_download_url": null,
167+
"api_data_url": "https://rubygems.org/api/v1/versions/github.json",
168168
"datasource_id": "gemspec",
169-
"purl": "pkg:gem/github@GitHub::VERSION"
169+
"purl": "pkg:gem/github"
170170
}
171171
]

tests/packagedcode/data/rubygems/gemspec/oj.gemspec-package-only.expected.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "gem",
44
"namespace": null,
55
"name": "oj",
6-
"version": "::Oj::VERSION",
6+
"version": null,
77
"qualifiers": {},
88
"subpath": null,
99
"primary_language": "Ruby",
@@ -27,7 +27,7 @@
2727
],
2828
"keywords": [],
2929
"homepage_url": "http://www.ohler.com/oj",
30-
"download_url": "https://rubygems.org/downloads/oj-::Oj::VERSION.gem",
30+
"download_url": null,
3131
"size": null,
3232
"sha1": null,
3333
"md5": null,
@@ -97,10 +97,10 @@
9797
"extra_data": {}
9898
}
9999
],
100-
"repository_homepage_url": "https://rubygems.org/gems/oj/versions/::Oj::VERSION",
101-
"repository_download_url": "https://rubygems.org/downloads/oj-::Oj::VERSION.gem",
102-
"api_data_url": "https://rubygems.org/api/v2/rubygems/oj/versions/::Oj::VERSION.json",
100+
"repository_homepage_url": "https://rubygems.org/gems/oj",
101+
"repository_download_url": null,
102+
"api_data_url": "https://rubygems.org/api/v1/versions/oj.json",
103103
"datasource_id": "gemspec",
104-
"purl": "pkg:gem/oj@::Oj::VERSION"
104+
"purl": "pkg:gem/oj"
105105
}
106106
]

tests/packagedcode/data/rubygems/gemspec/oj.gemspec.expected.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "gem",
44
"namespace": null,
55
"name": "oj",
6-
"version": "::Oj::VERSION",
6+
"version": null,
77
"qualifiers": {},
88
"subpath": null,
99
"primary_language": "Ruby",
@@ -27,7 +27,7 @@
2727
],
2828
"keywords": [],
2929
"homepage_url": "http://www.ohler.com/oj",
30-
"download_url": "https://rubygems.org/downloads/oj-::Oj::VERSION.gem",
30+
"download_url": null,
3131
"size": null,
3232
"sha1": null,
3333
"md5": null,
@@ -97,10 +97,10 @@
9797
"extra_data": {}
9898
}
9999
],
100-
"repository_homepage_url": "https://rubygems.org/gems/oj/versions/::Oj::VERSION",
101-
"repository_download_url": "https://rubygems.org/downloads/oj-::Oj::VERSION.gem",
102-
"api_data_url": "https://rubygems.org/api/v2/rubygems/oj/versions/::Oj::VERSION.json",
100+
"repository_homepage_url": "https://rubygems.org/gems/oj",
101+
"repository_download_url": null,
102+
"api_data_url": "https://rubygems.org/api/v1/versions/oj.json",
103103
"datasource_id": "gemspec",
104-
"purl": "pkg:gem/oj@::Oj::VERSION"
104+
"purl": "pkg:gem/oj"
105105
}
106106
]

tests/packagedcode/data/rubygems/gemspec/rubocop.gemspec.expected.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "gem",
44
"namespace": null,
55
"name": "rubocop",
6-
"version": "RuboCop::Version::STRING",
6+
"version": null,
77
"qualifiers": {},
88
"subpath": null,
99
"primary_language": "Ruby",
@@ -41,7 +41,7 @@
4141
],
4242
"keywords": [],
4343
"homepage_url": "https://github.com/rubocop-hq/rubocop",
44-
"download_url": "https://rubygems.org/downloads/rubocop-RuboCop::Version::STRING.gem",
44+
"download_url": null,
4545
"size": null,
4646
"sha1": null,
4747
"md5": null,
@@ -166,10 +166,10 @@
166166
"extra_data": {}
167167
}
168168
],
169-
"repository_homepage_url": "https://rubygems.org/gems/rubocop/versions/RuboCop::Version::STRING",
170-
"repository_download_url": "https://rubygems.org/downloads/rubocop-RuboCop::Version::STRING.gem",
171-
"api_data_url": "https://rubygems.org/api/v2/rubygems/rubocop/versions/RuboCop::Version::STRING.json",
169+
"repository_homepage_url": "https://rubygems.org/gems/rubocop",
170+
"repository_download_url": null,
171+
"api_data_url": "https://rubygems.org/api/v1/versions/rubocop.json",
172172
"datasource_id": "gemspec",
173-
"purl": "pkg:gem/rubocop@RuboCop::Version::STRING"
173+
"purl": "pkg:gem/rubocop"
174174
}
175175
]

tests/packagedcode/data/rubygems/gemspec/with_variables.gemspec.expected.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "gem",
44
"namespace": null,
55
"name": "ProviderDSL::GemDescription::NAME",
6-
"version": "ProviderDSL::GemDescription::VERSION",
6+
"version": null,
77
"qualifiers": {},
88
"subpath": null,
99
"primary_language": "Ruby",
@@ -27,7 +27,7 @@
2727
],
2828
"keywords": [],
2929
"homepage_url": "ProviderDSL::GemDescription::PAGE",
30-
"download_url": "https://rubygems.org/downloads/ProviderDSL::GemDescription::NAME-ProviderDSL::GemDescription::VERSION.gem",
30+
"download_url": null,
3131
"size": null,
3232
"sha1": null,
3333
"md5": null,
@@ -152,10 +152,10 @@
152152
"extra_data": {}
153153
}
154154
],
155-
"repository_homepage_url": "https://rubygems.org/gems/ProviderDSL::GemDescription::NAME/versions/ProviderDSL::GemDescription::VERSION",
156-
"repository_download_url": "https://rubygems.org/downloads/ProviderDSL::GemDescription::NAME-ProviderDSL::GemDescription::VERSION.gem",
157-
"api_data_url": "https://rubygems.org/api/v2/rubygems/ProviderDSL::GemDescription::NAME/versions/ProviderDSL::GemDescription::VERSION.json",
155+
"repository_homepage_url": "https://rubygems.org/gems/ProviderDSL::GemDescription::NAME",
156+
"repository_download_url": null,
157+
"api_data_url": "https://rubygems.org/api/v1/versions/ProviderDSL::GemDescription::NAME.json",
158158
"datasource_id": "gemspec",
159-
"purl": "pkg:gem/ProviderDSL::GemDescription::NAME@ProviderDSL::GemDescription::VERSION"
159+
"purl": "pkg:gem/ProviderDSL::GemDescription::NAME"
160160
}
161161
]
Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1-
404: Not Found
1+
# frozen_string_literal: true
2+
3+
require_relative 'lib/faraday/version'
4+
5+
Gem::Specification.new do |spec|
6+
spec.name = 'faraday'
7+
spec.version = Faraday::VERSION
8+
9+
spec.summary = 'HTTP/REST API client library.'
10+
11+
spec.authors = ['@technoweenie', '@iMacTia', '@olleolleolle']
12+
spec.email = 'technoweenie@gmail.com'
13+
spec.homepage = 'https://lostisland.github.io/faraday'
14+
spec.licenses = ['MIT']
15+
16+
spec.required_ruby_version = '>= 2.6'
17+
18+
# faraday-net_http is the "default adapter", but being a Faraday dependency it can't
19+
# control which version of faraday it will be pulled from.
20+
# To avoid releasing a major version every time there's a new Faraday API, we should
21+
# always fix its required version to the next MINOR version.
22+
# This way, we can release minor versions of the adapter with "breaking" changes for older versions of Faraday
23+
# and then bump the version requirement on the next compatible version of faraday.
24+
spec.add_dependency 'faraday-net_http', '>= 2.0', '< 3.1'
25+
spec.add_dependency 'ruby2_keywords', '>= 0.0.4'
26+
27+
# Includes `examples` and `spec` to allow external adapter gems to run Faraday unit and integration tests
28+
spec.files = Dir['CHANGELOG.md', '{examples,lib,spec}/**/*', 'LICENSE.md', 'Rakefile', 'README.md']
29+
spec.require_paths = %w[lib spec/external_adapters]
30+
spec.metadata = {
31+
'homepage_uri' => 'https://lostisland.github.io/faraday',
32+
'changelog_uri' =>
33+
"https://github.com/lostisland/faraday/releases/tag/v#{spec.version}",
34+
'source_code_uri' => 'https://github.com/lostisland/faraday',
35+
'bug_tracker_uri' => 'https://github.com/lostisland/faraday/issues'
36+
}
37+
end

tests/packagedcode/test_rubygems.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
from packages_test_utils import PackageTester
2020
from scancode_config import REGEN_TEST_FIXTURES
2121

22-
REGEN_TEST_FIXTURES = False
23-
2422
# TODO: Add test with https://rubygems.org/gems/pbox2d/versions/1.0.3-java
2523
# this is a multiple personality package (Java and Ruby)
2624
# see also https://rubygems.org/downloads/jaro_winkler-1.5.1-java.gem
@@ -29,23 +27,41 @@
2927
class TestGemspecVersionConstant(PackageTester):
3028
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
3129

32-
def test_version_constant_returns_none_for_elasticsearch(self):
33-
test_file = self.get_test_loc('rubygems/version-constant/elasticsearch-api.gemspec')
30+
def _check_version_constant_package(self, test_path, expected_name):
31+
test_file = self.get_test_loc(test_path)
3432
packages = list(rubygems.GemspecHandler.parse(test_file))
3533
assert packages
3634
pkg = packages[0]
37-
assert pkg.name == 'elasticsearch-api'
35+
assert pkg.name == expected_name
3836
assert pkg.version is None
39-
assert 'Elasticsearch' not in str(pkg.version)
4037
assert pkg.download_url is None
38+
assert pkg.api_data_url == f'https://rubygems.org/api/v1/versions/{expected_name}.json'
39+
return pkg
40+
41+
def test_version_constant_returns_none_for_elasticsearch(self):
42+
pkg = self._check_version_constant_package(
43+
test_path='rubygems/version-constant/elasticsearch-api.gemspec',
44+
expected_name='elasticsearch-api',
45+
)
46+
assert 'Elasticsearch' not in str(pkg.version)
47+
48+
def test_version_constant_returns_none_for_excon(self):
49+
self._check_version_constant_package(
50+
test_path='rubygems/version-constant/excon.gemspec',
51+
expected_name='excon',
52+
)
53+
54+
def test_version_constant_returns_none_for_faraday(self):
55+
self._check_version_constant_package(
56+
test_path='rubygems/version-constant/faraday.gemspec',
57+
expected_name='faraday',
58+
)
4159

4260
def test_version_constant_returns_none_for_simple_constant(self):
43-
test_file = self.get_test_loc('rubygems/version-constant/simple-constant.gemspec')
44-
packages = list(rubygems.GemspecHandler.parse(test_file))
45-
assert packages
46-
pkg = packages[0]
47-
assert pkg.name == 'my-gem'
48-
assert pkg.version is None
61+
self._check_version_constant_package(
62+
test_path='rubygems/version-constant/simple-constant.gemspec',
63+
expected_name='my-gem',
64+
)
4965

5066
def test_real_version_is_preserved(self):
5167
test_file = self.get_test_loc('rubygems/version-constant/simple-version.gemspec')

0 commit comments

Comments
 (0)