Skip to content

Commit b5afca3

Browse files
authored
[BC-17943] include step types (#8)
1 parent 29ad725 commit b5afca3

File tree

9 files changed

+53
-5
lines changed

9 files changed

+53
-5
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ gem 'bmt-ruby'
1414

1515
## Usage
1616

17-
TODO: Write usage instructions here
17+
For convenience in development, we provide a utility for spinning up a
18+
playground for playing with the gem. You can invoke it with:
19+
20+
```bash
21+
bin/console
22+
```

lib/bmt/step.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module BMT
22
class Step
3-
attr_reader :key, :title, :description, :methodology
3+
attr_reader :key, :title, :description, :methodology, :type
44

55
def initialize(methodology:, attributes:)
66
@methodology = methodology
77
@key = attributes['key']
88
@title = attributes['title']
99
@description = attributes['description']
10-
@items_data = attributes['items']
10+
@type = attributes['type']
11+
@items_data = attributes['items'] || []
1112
end
1213

1314
def items

lib/bmt/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Bmt
2-
VERSION = '0.2.0'.freeze
2+
VERSION = '0.3.0'.freeze
33
end

spec/bmt/methodology_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@
3838

3939
it 'returns a list of BMT Steps' do
4040
expect(subject.first).to be_a(BMT::Step)
41+
end
4142

43+
it 'returns the expected data' do
4244
expect(subject).to match_array(
4345
[
4446
an_object_having_attributes(
4547
key: 'koala',
4648
title: 'Check that you have a Koala',
4749
description: an_instance_of(String),
50+
type: 'checklist',
4851
items: match_array(
4952
[
5053
an_object_having_attributes(
@@ -70,6 +73,7 @@
7073
key: 'kangaroo',
7174
title: 'Ensure you have a kangaroo',
7275
description: an_instance_of(String),
76+
type: 'checklist',
7377
items: match_array(
7478
[
7579
an_object_having_attributes(
@@ -89,6 +93,13 @@
8993
)
9094
]
9195
)
96+
),
97+
an_object_having_attributes(
98+
key: 'executive_summary',
99+
title: 'Executive summary',
100+
description: an_instance_of(String),
101+
type: 'executive_summary',
102+
items: []
92103
)
93104
]
94105
)

spec/bmt/step_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,23 @@
4646
)
4747
end
4848
end
49+
50+
context 'with an executive_summary step type' do
51+
let(:attributes) { methodology_json.dig('content', 'steps', 2) }
52+
53+
subject do
54+
described_class.new(
55+
methodology: methodology,
56+
attributes: attributes
57+
)
58+
end
59+
60+
it 'returns the correct type' do
61+
expect(subject.type).to eq 'executive_summary'
62+
end
63+
64+
it 'returns no items' do
65+
expect(subject.items).to be_empty
66+
end
67+
end
4968
end

spec/sample/1.0/methodologies/website-testing.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"key": "information",
1212
"title": "Information gathering",
1313
"description": "",
14+
"type": "checklist",
1415
"items": [
1516
{
1617
"key": "search_engine_discovery_and_reconnaissance",
@@ -24,6 +25,7 @@
2425
"key": "config_and_deploy_management",
2526
"title": "Configuration and Deploy Management Testing",
2627
"description": "",
28+
"type": "checklist",
2729
"items": [
2830
{
2931
"key": "network_and_infrastructure",

spec/sample/2.1/methodologies/outback-animal-testing.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"key": "koala",
1212
"title": "Check that you have a Koala",
1313
"description": "# Does it look like one?\nIt is easy to find out.\n",
14+
"type": "checklist",
1415
"items": [
1516
{
1617
"key": "marsupial",
@@ -40,6 +41,7 @@
4041
"key": "kangaroo",
4142
"title": "Ensure you have a kangaroo",
4243
"description": "Does it look like one?",
44+
"type": "checklist",
4345
"items": [
4446
{
4547
"key": "marsupial",
@@ -57,6 +59,12 @@
5759
"description": "Over very short distances kangaroos will use their forepaws to balance on the ground and swing their legs forward. For longer distance movement, their jumping locomotion is unmistakeable."
5860
}
5961
]
62+
},
63+
{
64+
"key": "executive_summary",
65+
"title": "Executive summary",
66+
"description": "The executive summary should be written with a high-level view of both risk and business impact. It should be concise and clear, therefore it is important to use plain English. This ensures that non-technical readers can gain insight into security concerns outlined in your report.",
67+
"type": "executive_summary"
6068
}
6169
]
6270
}

spec/sample/2.1/methodologies/website-testing.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"key": "information",
1212
"title": "Information gathering",
1313
"description": "",
14+
"type": "checklist",
1415
"items": [
1516
{
1617
"key": "search_engine_discovery_and_reconnaissance",
@@ -24,6 +25,7 @@
2425
"key": "config_and_deploy_management",
2526
"title": "Configuration and Deploy Management Testing",
2627
"description": "",
28+
"type": "checklist",
2729
"items": [
2830
{
2931
"key": "network_and_infrastructure",

0 commit comments

Comments
 (0)