Sha256: 67767737329734fba981485da14674e3da849b61690c19f5f4304874c96b90ce

Contents?: true

Size: 1.56 KB

Versions: 20

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe ActiveFedora::Model do
  before(:each) do
    module ModelIntegrationSpec
      class Base < ActiveFedora::Base
        include ActiveFedora::Model
        def self.id_namespace
          "foo"
        end
        has_metadata name: "properties", type: ActiveFedora::SimpleDatastream, autocreate: true
      end
      class Basic < Base
      end
    end

    @test_instance = ModelIntegrationSpec::Basic.new
    @test_instance.save
  end

  after(:each) do
    @test_instance.delete
    Object.send(:remove_const, :ModelIntegrationSpec)
  end

  describe "#all" do
    it "returns an array of instances of the calling Class" do
      result = ModelIntegrationSpec::Basic.all.to_a
      expect(result).to be_instance_of(Array)
      # this test is meaningless if the array length is zero
      expect(result).to_not be_empty
      result.each do |obj|
        expect(obj.class).to eq ModelIntegrationSpec::Basic
      end
    end
  end

  describe '#find' do
    describe "#find with a valid id without cast" do
      subject { ActiveFedora::Base.find(@test_instance.id) }
      it { should be_instance_of ModelIntegrationSpec::Basic }
    end
    describe "#find with a valid id with cast of false" do
      subject { ActiveFedora::Base.find(@test_instance.id, cast: false) }
      it { should be_instance_of ActiveFedora::Base }
    end
    describe "#find with a valid id without cast on a model extending Base" do
      subject { ModelIntegrationSpec::Basic.find(@test_instance.id) }
      it { should be_instance_of ModelIntegrationSpec::Basic }
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active-fedora-9.7.3 spec/integration/model_spec.rb
active-fedora-9.7.2 spec/integration/model_spec.rb
active-fedora-9.12.0 spec/integration/model_spec.rb
active-fedora-9.11.0 spec/integration/model_spec.rb
active-fedora-9.10.4 spec/integration/model_spec.rb
active-fedora-9.10.3 spec/integration/model_spec.rb
active-fedora-9.10.2 spec/integration/model_spec.rb
active-fedora-9.10.1 spec/integration/model_spec.rb
active-fedora-9.10.0 spec/integration/model_spec.rb
active-fedora-9.10.0.pre2 spec/integration/model_spec.rb
active-fedora-9.10.0.pre1 spec/integration/model_spec.rb
active-fedora-9.9.1 spec/integration/model_spec.rb
active-fedora-9.9.0 spec/integration/model_spec.rb
active-fedora-9.8.2 spec/integration/model_spec.rb
active-fedora-9.8.1 spec/integration/model_spec.rb
active-fedora-9.8.0 spec/integration/model_spec.rb
active-fedora-9.7.1 spec/integration/model_spec.rb
active-fedora-9.7.0 spec/integration/model_spec.rb
active-fedora-9.6.2 spec/integration/model_spec.rb
active-fedora-9.6.1 spec/integration/model_spec.rb