Sha256: 7bc8a603eefb662648655f16bea93bb2ee3282b14da552e4238a856fc4af38f2

Contents?: true

Size: 1.4 KB

Versions: 34

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe ActiveFedora::FilesHash do
  before do
    class FilesContainer; end
    allow(FilesContainer).to receive(:child_resource_reflections).and_return(file: reflection)
    allow(container).to receive(:association).with(:file).and_return(association)
    allow(container).to receive(:undeclared_files).and_return([])
  end

  after { Object.send(:remove_const, :FilesContainer) }

  let(:reflection) { double('reflection') }
  let(:association) { double('association', reader: object) }
  let(:object) { double('object') }
  let(:container) { FilesContainer.new }

  subject { described_class.new(container) }

  describe "#key?" do
    context 'when the key is present' do
      it "is true" do
        expect(subject.key?(:file)).to be true
      end
      it "returns true if a string is passed" do
        expect(subject.key?('file')).to be true
      end
    end

    context 'when the key is not present' do
      it "is false" do
        expect(subject.key?(:foo)).to be false
      end
    end
  end

  describe "#[]" do
    context 'when the key is present' do
      it "returns the object" do
        expect(subject[:file]).to eq object
      end
      it "returns the object if a string is passed" do
        expect(subject['file']).to eq object
      end
    end

    context 'when the key is not present' do
      it "is nil" do
        expect(subject[:foo]).to be_nil
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
active-fedora-10.3.0 spec/unit/files_hash_spec.rb
active-fedora-9.7.3 spec/unit/files_hash_spec.rb
active-fedora-10.3.0.rc2 spec/unit/files_hash_spec.rb
active-fedora-10.3.0.rc1 spec/unit/files_hash_spec.rb
active-fedora-10.2.1 spec/unit/files_hash_spec.rb
active-fedora-10.2.0 spec/unit/files_hash_spec.rb
active-fedora-11.0.0.rc1 spec/unit/files_hash_spec.rb
active-fedora-10.1.0 spec/unit/files_hash_spec.rb
active-fedora-10.1.0.rc1 spec/unit/files_hash_spec.rb
active-fedora-9.7.2 spec/unit/files_hash_spec.rb
active-fedora-10.0.0 spec/unit/files_hash_spec.rb
active-fedora-10.0.0.beta4 spec/unit/files_hash_spec.rb
active-fedora-10.0.0.beta3 spec/unit/files_hash_spec.rb
active-fedora-10.0.0.beta2 spec/unit/files_hash_spec.rb
active-fedora-10.0.0.beta1 spec/unit/files_hash_spec.rb
active-fedora-9.13.0 spec/unit/files_hash_spec.rb
active-fedora-9.12.0 spec/unit/files_hash_spec.rb
active-fedora-9.11.0 spec/unit/files_hash_spec.rb
active-fedora-9.10.4 spec/unit/files_hash_spec.rb
active-fedora-9.10.3 spec/unit/files_hash_spec.rb