Sha256: 8b493de40af34894911dd57e74e368cb7ffc9c23b7db4245019c5ed6f1858406

Contents?: true

Size: 837 Bytes

Versions: 16

Compression:

Stored size: 837 Bytes

Contents

require "spec_helper"
require "lutaml/model/yaml_adapter"
require_relative "../../fixtures/sample_model"

RSpec.shared_examples "a YAML adapter" do |adapter_class|
  let(:attributes) { { "name" => "John Doe", "age" => 30 } }
  let(:model) { SampleModel.new(attributes) }

  let(:expected_yaml) do
    if adapter_class == Lutaml::Model::YamlAdapter::StandardYamlAdapter
      attributes.to_yaml
    end
  end

  it "serializes to YAML" do
    yaml = adapter_class.new(attributes).to_yaml

    expect(yaml).to eq(expected_yaml)
  end

  it "deserializes from YAML" do
    new_model = adapter_class.parse(expected_yaml)
    expect(new_model["name"]).to eq("John Doe")
    expect(new_model["age"]).to eq(30)
  end
end

RSpec.describe Lutaml::Model::YamlAdapter::StandardYamlAdapter do
  it_behaves_like "a YAML adapter", described_class
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lutaml-model-0.6.3 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.6.2 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.6.1 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.6.0 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.5.4 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.5.3 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.5.2 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.5.1 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.5.0 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.4.0 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.3.30 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.3.29 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.3.28 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.3.27 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.3.26 spec/lutaml/model/yaml_adapter_spec.rb
lutaml-model-0.3.25 spec/lutaml/model/yaml_adapter_spec.rb