Sha256: c6d739471c7e2b2369075a72438ffbb3e07a318f2760b911e57737791d9b7e10

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative "../spec_helper"

RSpec.describe Oscal::Catalog do
  let(:subject) do
    Oscal::Catalog.load_from_yaml(
      "spec/oscal-content/examples/catalog/yaml/basic-catalog.yaml",
    )
  end

  it "parses oscal-content YAML" do
    expect(subject.class).to be Oscal::Catalog
    expect(subject.groups.first.groups.first.controls.first.parts.first.prose).to eq(
      "To establish a management framework to initiate and " \
      "control the implementation and operation of information security " \
      "within the organization.",
    )
  end

  it "gets all controls" do
    expect(subject.class).to be Oscal::Catalog
    expect(subject.get_all_controls.count).to eq(4)
  end

  it "find object by id" do
    obj = subject.find_object_by_id("s2.1_smt")
    expect(obj.to_s).to match(/Oscal::Part/)
    expect(obj.prose).to eq(
      "To limit access to information and information processing facilities.",
    )
  end

  it "find object by uuid" do
    uuid = "74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724"
    obj = subject.find_object_by_id(
      uuid, subject, :uuid
    )
    expect(obj.to_s).to match(/Oscal::Catalog/)
    expect(obj.uuid).to eq(uuid)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oscal-0.2.3 spec/oscal/catalog_spec.rb