Sha256: 0807fd96324252f64e74056338212f2f3f9d3b6b5cfe22ea896abb6dc946c930

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe ActiveFedora::Scoping::Named do
  before do
    class TestClass < ActiveFedora::Base
    end
  end
  let!(:test_instance) { TestClass.create! }

  after do
    test_instance.delete
    Object.send(:remove_const, :TestClass)
  end

  describe "#all" do
    it "returns an array of instances of the calling Class" do
      result = TestClass.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 TestClass
      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 TestClass }
    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 { TestClass.find(test_instance.id) }
      it { should be_instance_of TestClass }
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
active-fedora-10.3.0 spec/integration/scoping_spec.rb
active-fedora-11.0.1 spec/integration/scoping_spec.rb
active-fedora-11.0.0 spec/integration/scoping_spec.rb
active-fedora-10.3.0.rc2 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc7 spec/integration/scoping_spec.rb
active-fedora-10.3.0.rc1 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc6 spec/integration/scoping_spec.rb
active-fedora-10.2.1 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc5 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc4 spec/integration/scoping_spec.rb
active-fedora-10.2.0 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc3 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc2 spec/integration/scoping_spec.rb
active-fedora-11.0.0.rc1 spec/integration/scoping_spec.rb
active-fedora-10.1.0 spec/integration/scoping_spec.rb
active-fedora-10.1.0.rc1 spec/integration/scoping_spec.rb
active-fedora-10.0.0 spec/integration/scoping_spec.rb
active-fedora-10.0.0.beta4 spec/integration/scoping_spec.rb
active-fedora-10.0.0.beta3 spec/integration/scoping_spec.rb
active-fedora-10.0.0.beta2 spec/integration/scoping_spec.rb