|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'spec_helper' |
| 4 | + |
| 5 | +describe BMT::Methodology do |
| 6 | + describe '#new' do |
| 7 | + subject do |
| 8 | + described_class.new(key: methodology_key, |
| 9 | + version: version, |
| 10 | + attributes: methodology_json) |
| 11 | + end |
| 12 | + |
| 13 | + context 'with valid args' do |
| 14 | + let(:methodology_key) { 'outback-animal-testing' } |
| 15 | + let(:version) { '2.1' } |
| 16 | + let(:methodology_json) { BMT.methodology_json(methodology_key) } |
| 17 | + |
| 18 | + it 'initialize a methodology' do |
| 19 | + expect(subject).to be_a(described_class) |
| 20 | + |
| 21 | + expect(subject.key).to eq('outback-animal-testing') |
| 22 | + expect(subject.title).to eq('The Outback Animal Checklist') |
| 23 | + expect(subject.description).to be_a(String) |
| 24 | + end |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + describe '#steps' do |
| 29 | + subject do |
| 30 | + described_class.new(key: methodology_key, |
| 31 | + version: version, |
| 32 | + attributes: methodology_json).steps |
| 33 | + end |
| 34 | + |
| 35 | + let(:methodology_key) { 'outback-animal-testing' } |
| 36 | + let(:version) { '2.1' } |
| 37 | + let(:methodology_json) { BMT.methodology_json(methodology_key) } |
| 38 | + |
| 39 | + it 'returns a list of BMT Steps' do |
| 40 | + expect(subject.first).to be_a(BMT::Step) |
| 41 | + |
| 42 | + expect(subject).to match_array( |
| 43 | + [ |
| 44 | + an_object_having_attributes( |
| 45 | + key: 'koala', |
| 46 | + title: 'Check that you have a Koala', |
| 47 | + description: an_instance_of(String), |
| 48 | + items: match_array( |
| 49 | + [ |
| 50 | + an_object_having_attributes( |
| 51 | + key: 'marsupial', |
| 52 | + title: an_instance_of(String), |
| 53 | + description: an_instance_of(String), |
| 54 | + vrt_category: an_instance_of(String) |
| 55 | + ), |
| 56 | + an_object_having_attributes( |
| 57 | + key: 'diet', |
| 58 | + title: an_instance_of(String), |
| 59 | + description: an_instance_of(String) |
| 60 | + ), |
| 61 | + an_object_having_attributes( |
| 62 | + key: 'behavior', |
| 63 | + title: an_instance_of(String), |
| 64 | + description: an_instance_of(String) |
| 65 | + ) |
| 66 | + ] |
| 67 | + ) |
| 68 | + ), |
| 69 | + an_object_having_attributes( |
| 70 | + key: 'kangaroo', |
| 71 | + title: 'Ensure you have a kangaroo', |
| 72 | + description: an_instance_of(String), |
| 73 | + items: match_array( |
| 74 | + [ |
| 75 | + an_object_having_attributes( |
| 76 | + key: 'marsupial', |
| 77 | + title: an_instance_of(String), |
| 78 | + description: an_instance_of(String) |
| 79 | + ), |
| 80 | + an_object_having_attributes( |
| 81 | + key: 'tail', |
| 82 | + title: an_instance_of(String), |
| 83 | + description: an_instance_of(String) |
| 84 | + ), |
| 85 | + an_object_having_attributes( |
| 86 | + key: 'jump', |
| 87 | + title: an_instance_of(String), |
| 88 | + description: an_instance_of(String) |
| 89 | + ) |
| 90 | + ] |
| 91 | + ) |
| 92 | + ) |
| 93 | + ] |
| 94 | + ) |
| 95 | + end |
| 96 | + end |
| 97 | +end |
0 commit comments