Sha256: 8e49e747a17e53a089a53732c995f736ad0c0fe4da1f40df6ec5a3bc51787f90

Contents?: true

Size: 1.43 KB

Versions: 23

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe ActiveFedora::FilesHash do
  before do
    class Container; end
    allow(Container).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, :Container) }

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

  subject { ActiveFedora::FilesHash.new(container) }

  describe "#key?" do
    context 'when the key is present' do
      it "should be true" do
        expect(subject.key?(:file)).to be true
      end
      it "should return 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 "should be false" do
        expect(subject.key?(:foo)).to be false
      end
    end
  end

  describe "#[]" do
    context 'when the key is present' do
      it "should return the object" do
        expect(subject[:file]).to eq object
      end
      it "should return 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 "should be nil" do
        expect(subject[:foo]).to be_nil
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active-fedora-9.0.8 spec/unit/files_hash_spec.rb
active-fedora-9.1.2 spec/unit/files_hash_spec.rb
active-fedora-9.1.1 spec/unit/files_hash_spec.rb
active-fedora-9.1.0 spec/unit/files_hash_spec.rb
active-fedora-9.1.0.rc1 spec/unit/files_hash_spec.rb
active-fedora-9.0.6 spec/unit/files_hash_spec.rb
active-fedora-9.0.5 spec/unit/files_hash_spec.rb
active-fedora-9.0.4 spec/unit/files_hash_spec.rb
active-fedora-9.0.3 spec/unit/files_hash_spec.rb
active-fedora-9.0.2 spec/unit/files_hash_spec.rb
active-fedora-9.0.1 spec/unit/files_hash_spec.rb
active-fedora-9.0.0 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.rc3 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.rc2 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.rc1 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.beta8 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.beta7 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.beta6 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.beta5 spec/unit/files_hash_spec.rb
active-fedora-9.0.0.beta4 spec/unit/files_hash_spec.rb