Sha256: c2944bb7ddada72fe4543f1b5f1b47e661832c0f342ed5f4398852e1323b4796

Contents?: true

Size: 861 Bytes

Versions: 41

Compression:

Stored size: 861 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') }

    let(:json) { JSON.parse(obj.to_json) }

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

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
active-fedora-12.2.4 spec/integration/json_serialization_spec.rb
active-fedora-12.2.3 spec/integration/json_serialization_spec.rb
active-fedora-11.5.6 spec/integration/json_serialization_spec.rb
active-fedora-12.2.2 spec/integration/json_serialization_spec.rb
active-fedora-11.2.1 spec/integration/json_serialization_spec.rb
active-fedora-12.2.1 spec/integration/json_serialization_spec.rb
active-fedora-12.0.3 spec/integration/json_serialization_spec.rb
active-fedora-11.5.5 spec/integration/json_serialization_spec.rb
active-fedora-13.1.2 spec/integration/json_serialization_spec.rb
active-fedora-13.1.1 spec/integration/json_serialization_spec.rb
active-fedora-13.1.0 spec/integration/json_serialization_spec.rb
active-fedora-13.0.0 spec/integration/json_serialization_spec.rb
active-fedora-12.1.1 spec/integration/json_serialization_spec.rb
active-fedora-12.1.0 spec/integration/json_serialization_spec.rb
active-fedora-11.5.4 spec/integration/json_serialization_spec.rb
active-fedora-11.5.3 spec/integration/json_serialization_spec.rb
active-fedora-12.0.2 spec/integration/json_serialization_spec.rb
active-fedora-12.0.1 spec/integration/json_serialization_spec.rb
active-fedora-11.5.2 spec/integration/json_serialization_spec.rb
active-fedora-12.0.0 spec/integration/json_serialization_spec.rb