Sha256: 7e0993fb6c97e8d68bc495fad4b0dd3a2f98b801f011df5c088c68d00a279e7c

Contents?: true

Size: 1.6 KB

Versions: 33

Compression:

Stored size: 1.6 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 "should return 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

33 entries across 33 versions & 1 rubygems

Version Path
active-fedora-9.0.8 spec/integration/model_spec.rb
active-fedora-9.5.0 spec/integration/model_spec.rb
active-fedora-9.4.3 spec/integration/model_spec.rb
active-fedora-9.4.2 spec/integration/model_spec.rb
active-fedora-9.4.1 spec/integration/model_spec.rb
active-fedora-9.4.0 spec/integration/model_spec.rb
active-fedora-9.3.0 spec/integration/model_spec.rb
active-fedora-9.2.1 spec/integration/model_spec.rb
active-fedora-9.2.0 spec/integration/model_spec.rb
active-fedora-9.2.0.rc2 spec/integration/model_spec.rb
active-fedora-9.2.0.rc1 spec/integration/model_spec.rb
active-fedora-9.1.2 spec/integration/model_spec.rb
active-fedora-9.1.1 spec/integration/model_spec.rb
active-fedora-9.1.0 spec/integration/model_spec.rb
active-fedora-9.1.0.rc1 spec/integration/model_spec.rb
active-fedora-9.0.6 spec/integration/model_spec.rb
active-fedora-9.0.5 spec/integration/model_spec.rb
active-fedora-9.0.4 spec/integration/model_spec.rb
active-fedora-9.0.3 spec/integration/model_spec.rb
active-fedora-9.0.2 spec/integration/model_spec.rb