Files
openfoodnetwork/engines/dfc_provider/spec/services/dfc_loader_spec.rb
Maikel Linke 191c4a79db Load spec helpers before Rails is loaded
Using Spring was hiding an loading error. When you start Rspec, Rails
and its engines are not loaded yet. So our way to load the spec helper
via `Rails.root` did not work when you ran specs on their own without
loading Rails with Spring first.
2023-09-11 14:57:38 +10:00

25 lines
653 B
Ruby

# frozen_string_literal: true
require_relative "../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