Files
openfoodnetwork/engines/dfc_provider/spec/services/dfc_loader_spec.rb
Maikel Linke 3b5b9ec54d Avoid network request to DFC context on export
This protects us from the DFC website going down or the DFC updating
the context with breaking changes. We are in control of updating the
context now (opt-in to newer versions).
2023-07-27 15:38:36 +10:00

25 lines
677 B
Ruby

# frozen_string_literal: true
require DfcProvider::Engine.root.join("spec/spec_helper")
describe DfcLoader do
it "prepares the DFC Connector to provide DFC object classes for export" do
tomato = DataFoodConsortium::Connector::SuppliedProduct.new(
"https://openfoodnetwork.org/tomato",
name: "Tomato",
description: "Awesome tomato",
)
expect(tomato.name).to eq "Tomato"
expect(tomato.description).to eq "Awesome tomato"
json = DfcIo.export(tomato)
result = JSON.parse(json)
expect(result.keys).to include(
*%w(@context @type dfc-b:name dfc-b:description)
)
expect(result["dfc-b:name"]).to eq "Tomato"
end
end