Skip to content

Commit

Permalink
adding specs for uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanAkbar committed Nov 21, 2023
1 parent fde673d commit 135442b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions spec/unit/concept_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@
.not_to raise_error
end

it "generates a uuid if not given" do
concept = described_class.new(attrs)
uuid = Glossarist::Utilities::UUID.uuid_v5(
Glossarist::Utilities::UUID::OID_NAMESPACE,
concept.to_h.to_s
)

expect(concept.uuid).to eq(uuid)
end

it "assign a uuid if given" do
concept = described_class.new(attrs.merge("uuid" => "abc"))

expect(concept.uuid).to eq("abc")
end

it "accepts a hash of attributes and create a concept" do
related = [
{
Expand Down
12 changes: 10 additions & 2 deletions spec/unit/managed_concept_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,16 @@
end

describe "#[]" do
it "returns a managed concept" do
managed_concept = Glossarist::ManagedConcept.new("data" => { id: "id" })
let(:managed_concept) { Glossarist::ManagedConcept.new("data" => { id: "id" }) }

it "returns a managed concept by uuid" do
managed_concept_collection.store(managed_concept)
uuid = Glossarist::Utilities::UUID.uuid_v5(Glossarist::Utilities::UUID::OID_NAMESPACE, managed_concept.to_h.to_s)

expect(managed_concept_collection[uuid]).to eq(managed_concept)
end

it "returns a managed concept by id" do
managed_concept_collection.store(managed_concept)

expect(managed_concept_collection["id"]).to eq(managed_concept)
Expand Down

0 comments on commit 135442b

Please sign in to comment.