Skip to content

Commit

Permalink
[BC-17943] include step types (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
fedetaglia authored Dec 10, 2021
1 parent 29ad725 commit b5afca3
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 5 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ gem 'bmt-ruby'

## Usage

TODO: Write usage instructions here
For convenience in development, we provide a utility for spinning up a
playground for playing with the gem. You can invoke it with:

```bash
bin/console
```
5 changes: 3 additions & 2 deletions lib/bmt/step.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module BMT
class Step
attr_reader :key, :title, :description, :methodology
attr_reader :key, :title, :description, :methodology, :type

def initialize(methodology:, attributes:)
@methodology = methodology
@key = attributes['key']
@title = attributes['title']
@description = attributes['description']
@items_data = attributes['items']
@type = attributes['type']
@items_data = attributes['items'] || []
end

def items
Expand Down
2 changes: 1 addition & 1 deletion lib/bmt/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bmt
VERSION = '0.2.0'.freeze
VERSION = '0.3.0'.freeze
end
2 changes: 1 addition & 1 deletion lib/data/0.1
11 changes: 11 additions & 0 deletions spec/bmt/methodology_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@

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

it 'returns the expected data' do
expect(subject).to match_array(
[
an_object_having_attributes(
key: 'koala',
title: 'Check that you have a Koala',
description: an_instance_of(String),
type: 'checklist',
items: match_array(
[
an_object_having_attributes(
Expand All @@ -70,6 +73,7 @@
key: 'kangaroo',
title: 'Ensure you have a kangaroo',
description: an_instance_of(String),
type: 'checklist',
items: match_array(
[
an_object_having_attributes(
Expand All @@ -89,6 +93,13 @@
)
]
)
),
an_object_having_attributes(
key: 'executive_summary',
title: 'Executive summary',
description: an_instance_of(String),
type: 'executive_summary',
items: []
)
]
)
Expand Down
19 changes: 19 additions & 0 deletions spec/bmt/step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,23 @@
)
end
end

context 'with an executive_summary step type' do
let(:attributes) { methodology_json.dig('content', 'steps', 2) }

subject do
described_class.new(
methodology: methodology,
attributes: attributes
)
end

it 'returns the correct type' do
expect(subject.type).to eq 'executive_summary'
end

it 'returns no items' do
expect(subject.items).to be_empty
end
end
end
2 changes: 2 additions & 0 deletions spec/sample/1.0/methodologies/website-testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"key": "information",
"title": "Information gathering",
"description": "",
"type": "checklist",
"items": [
{
"key": "search_engine_discovery_and_reconnaissance",
Expand All @@ -24,6 +25,7 @@
"key": "config_and_deploy_management",
"title": "Configuration and Deploy Management Testing",
"description": "",
"type": "checklist",
"items": [
{
"key": "network_and_infrastructure",
Expand Down
8 changes: 8 additions & 0 deletions spec/sample/2.1/methodologies/outback-animal-testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"key": "koala",
"title": "Check that you have a Koala",
"description": "# Does it look like one?\nIt is easy to find out.\n",
"type": "checklist",
"items": [
{
"key": "marsupial",
Expand Down Expand Up @@ -40,6 +41,7 @@
"key": "kangaroo",
"title": "Ensure you have a kangaroo",
"description": "Does it look like one?",
"type": "checklist",
"items": [
{
"key": "marsupial",
Expand All @@ -57,6 +59,12 @@
"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."
}
]
},
{
"key": "executive_summary",
"title": "Executive summary",
"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.",
"type": "executive_summary"
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions spec/sample/2.1/methodologies/website-testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"key": "information",
"title": "Information gathering",
"description": "",
"type": "checklist",
"items": [
{
"key": "search_engine_discovery_and_reconnaissance",
Expand All @@ -24,6 +25,7 @@
"key": "config_and_deploy_management",
"title": "Configuration and Deploy Management Testing",
"description": "",
"type": "checklist",
"items": [
{
"key": "network_and_infrastructure",
Expand Down

0 comments on commit b5afca3

Please sign in to comment.