Sha256: 5cb71eaaec844e042e1893f8872bef3d208dbee5316a3b18052edb835158c428

Contents?: true

Size: 867 Bytes

Versions: 13

Compression:

Stored size: 867 Bytes

Contents

require 'spec_helper'

describe "Objects should be serialized to JSON" do
  it "has json results" do
    expect(ActiveFedora::Base.new.to_json).to eq "{\"id\":null}"
  end

  context "with properties" do
    before do
      class Foo < ActiveFedora::Base
        property :title, predicate: ::RDF::Vocab::DC.title
        property :description, predicate: ::RDF::Vocab::DC.description, multiple: false
      end
    end

    after do
      Object.send(:remove_const, :Foo)
    end

    let(:obj) { Foo.new(title: ['My Title'], description: 'Wonderful stuff') }

    before { allow(obj).to receive(:id).and_return('test-123') }

    subject { JSON.parse(obj.to_json) }

    it "has to_json" do
      expect(subject['id']).to eq "test-123"
      expect(subject['title']).to eq ["My Title"]
      expect(subject['description']).to eq "Wonderful stuff"
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active-fedora-10.3.0 spec/integration/json_serialization_spec.rb
active-fedora-10.3.0.rc2 spec/integration/json_serialization_spec.rb
active-fedora-10.3.0.rc1 spec/integration/json_serialization_spec.rb
active-fedora-10.2.1 spec/integration/json_serialization_spec.rb
active-fedora-10.2.0 spec/integration/json_serialization_spec.rb
active-fedora-11.0.0.rc1 spec/integration/json_serialization_spec.rb
active-fedora-10.1.0 spec/integration/json_serialization_spec.rb
active-fedora-10.1.0.rc1 spec/integration/json_serialization_spec.rb
active-fedora-10.0.0 spec/integration/json_serialization_spec.rb
active-fedora-10.0.0.beta4 spec/integration/json_serialization_spec.rb
active-fedora-10.0.0.beta3 spec/integration/json_serialization_spec.rb
active-fedora-10.0.0.beta2 spec/integration/json_serialization_spec.rb
active-fedora-10.0.0.beta1 spec/integration/json_serialization_spec.rb