-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marlon Pina Tojal <[email protected]>
- Loading branch information
Marlon Pina Tojal
committed
Dec 9, 2023
1 parent
52ccf2c
commit 2706034
Showing
1 changed file
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
|
||
require 'cyclonedx/cocoapods/podfile_analyzer' | ||
require 'rspec' | ||
|
||
RSpec.describe CycloneDX::CocoaPods::PodfileAnalyzer do | ||
let(:fixtures) { Pathname.new(File.expand_path('../../../fixtures/', __FILE__)) } | ||
let(:empty_podfile) { 'EmptyPodfile/Podfile' } | ||
|
@@ -125,4 +124,59 @@ | |
end | ||
end | ||
end | ||
context 'parsing dependencies' do | ||
context 'when created with standard parameters' do | ||
it 'should handle no dependencies correctly' do | ||
analyzer = ::CycloneDX::CocoaPods::PodfileAnalyzer.new(logger: @logger) | ||
|
||
pod_file = ::Pod::Podfile.from_file(fixtures + empty_podfile) | ||
expect(pod_file).not_to be_nil | ||
lock_file = ::Pod::Lockfile.from_file(fixtures + (empty_podfile + '.lock')) | ||
expect(lock_file).not_to be_nil | ||
|
||
dependencies = analyzer.dependencies_hash_of_lockfile_pods(pod_file, lock_file) | ||
|
||
expect(dependencies).to eq({}) | ||
end | ||
|
||
it 'should find all dependencies correctly (simple_pod)' do | ||
analyzer = ::CycloneDX::CocoaPods::PodfileAnalyzer.new(logger: @logger) | ||
|
||
pod_file = ::Pod::Podfile.from_file(fixtures + simple_pod) | ||
expect(pod_file).not_to be_nil | ||
lock_file = ::Pod::Lockfile.from_file(fixtures + (simple_pod + '.lock')) | ||
expect(lock_file).not_to be_nil | ||
|
||
dependencies = analyzer.dependencies_hash_of_lockfile_pods(pod_file, lock_file) | ||
|
||
expect(dependencies).to eq({" pkg:cocoapods/[email protected]" => [], "pkg:cocoapods/[email protected]" => [ "pkg:cocoapods/[email protected]#app-lib" ], "pkg:cocoapods/[email protected]#app-lib" => [] }) | ||
end | ||
|
||
it 'should find all dependencies correctly (restricted_pod)' do | ||
analyzer = ::CycloneDX::CocoaPods::PodfileAnalyzer.new(logger: @logger) | ||
|
||
pod_file = ::Pod::Podfile.from_file(fixtures + restricted_pod) | ||
expect(pod_file).not_to be_nil | ||
lock_file = ::Pod::Lockfile.from_file(fixtures + (restricted_pod + '.lock')) | ||
expect(lock_file).not_to be_nil | ||
|
||
dependencies = analyzer.dependencies_hash_of_lockfile_pods(pod_file, lock_file) | ||
|
||
expect(dependencies).to eq({ "pkg:cocoapods/[email protected]" => [ "pkg:cocoapods/swift_qrcodejs@" ] }) | ||
end | ||
|
||
it 'should find all dependencies correctly (tests_pod)' do | ||
analyzer = ::CycloneDX::CocoaPods::PodfileAnalyzer.new(logger: @logger) | ||
|
||
pod_file = ::Pod::Podfile.from_file(fixtures + tests_pod) | ||
expect(pod_file).not_to be_nil | ||
lock_file = ::Pod::Lockfile.from_file(fixtures + (tests_pod + '.lock')) | ||
expect(lock_file).not_to be_nil | ||
|
||
dependencies = analyzer.dependencies_hash_of_lockfile_pods(pod_file, lock_file) | ||
|
||
expect(dependencies).to eq({ "pkg:cocoapods/[email protected]" => [] , "pkg:cocoapods/[email protected]" => ["pkg:cocoapods/[email protected]#app-lib"] , "pkg:cocoapods/[email protected]#app-lib" => [] }) | ||
end | ||
end | ||
end | ||
end |