Sha256: dde0b96264886b997e8d2ef3693f14c831c9421188ad40b02529665cefd13efc

Contents?: true

Size: 957 Bytes

Versions: 5

Compression:

Stored size: 957 Bytes

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  before :all do
    class Library < ActiveFedora::Base 
      has_many :books, property: :has_member
    end
    class Book < ActiveFedora::Base; end
  end
  after :all do
    Library.delete_all
    Object.send(:remove_const, :Library)
    Object.send(:remove_const, :Book)
  end

  subject {Library.all} 
  its(:class) {should eq ActiveFedora::Relation }

  describe "#find" do
    before do
      Library.create
      @library = Library.create
    end
    it "should find one of them" do
      expect(subject.find(@library.id)).to eq @library
    end
    it "should find with a block" do
      expect(subject.find { |l| l.id == @library.id}).to eq @library
    end
  end

  describe "#select" do
    before do
      Library.create
      @library = Library.create
    end
    it "should find with a block" do
      expect(subject.select { |l| l.id == @library.id}).to eq [@library]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active-fedora-7.0.0.rc2 spec/integration/relation_spec.rb
active-fedora-7.0.0.rc1 spec/integration/relation_spec.rb
active-fedora-7.0.0.pre3 spec/integration/relation_spec.rb
active-fedora-7.0.0.pre2 spec/integration/relation_spec.rb
active-fedora-7.0.0.pre1 spec/integration/relation_spec.rb