Skip to content

Commit 207dd44

Browse files
committed
Adds feature for Json format
Signed-off-by: M. Scott Ford <[email protected]>
1 parent a4703d7 commit 207dd44

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

features/json_format.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Creating BOM using Json format
2+
3+
Scenario: Running against simple fixture
4+
Given I use a fixture named "simple"
5+
And I run `cyclonedx-ruby --path . --format json`
6+
Then the output should contain:
7+
"""
8+
5 gems were written to BOM located at ./bom.json
9+
"""
10+
And a file named "bom.json" should exist
11+
And the generated XML Json file "bom.json" matches "bom.json.expected"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Then('the generated XML Json file {string} matches {string}') do |generated_file, expected_file|
2+
generated_file_contents = File.read(expand_path(generated_file))
3+
expected_file_contents = File.read(expand_path(expected_file))
4+
5+
# "serialNumber": "urn:uuid:d498cdc2-5494-4031-b37d-ff3d10d336bf"
6+
serial_number_matcher = /\"serialNumber\": \"urn:uuid:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"/
7+
normalized_serial_number = '"serialNumber": "urn:uuid:00000000-0000-0000-0000-000000000000"'
8+
normalized_generated_file_contents = generated_file_contents.gsub(serial_number_matcher, normalized_serial_number)
9+
normalized_expected_file_contents = expected_file_contents.gsub(serial_number_matcher, normalized_serial_number)
10+
11+
expect(normalized_expected_file_contents).to eq(normalized_generated_file_contents)
12+
end

0 commit comments

Comments
 (0)