Sha256: cc457dc3a697c9dc555357ae3f5a6a0240f90c5b8bfb279714660fc317aa68de

Contents?: true

Size: 1.29 KB

Versions: 36

Compression:

Stored size: 1.29 KB

Contents

RSpec.shared_examples "an object that has a display title" do
  describe "#title_display" do
    let(:object) { described_class.new }
    subject { object.title_display }
    context "has title" do
      before { object.title = [ 'Title' ] }
      it "should return the first title" do
        expect(subject).to eq('Title')
      end
    end
    context "has no title, has identifier" do
      before { object.identifier = [ 'id001' ] }
      it "should return the first identifier" do
        expect(subject).to eq('id001')
      end
    end
    # Only objects with content implement :original_filename
    # This test worked before b/c allowing rspec to stub methods
    # that aren't defined on object. This rspec-mocks config setting prevents that:
    #
    #   verify_partial_doubles = true
    #
    # context "has no title, no identifier, has original_filename" do
    #   before { allow(object).to receive(:original_filename) { "file.txt" } }
    #   it "should return original_filename" do
    #     expect(subject).to eq "file.txt"
    #   end
    # end
    context "has no title, no identifier, no original_filename" do
      let(:object) { described_class.new(:pid => 'duke:test') }
      it "should return the PID in square brackets" do
        expect(subject).to eq "[duke:test]"
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ddr-models-1.17.1 spec/support/shared_examples_for_indexing.rb
ddr-models-1.17.0 spec/support/shared_examples_for_indexing.rb
ddr-models-1.16.2 spec/support/shared_examples_for_indexing.rb
ddr-models-1.16.1 spec/support/shared_examples_for_indexing.rb
ddr-models-1.16.0 spec/support/shared_examples_for_indexing.rb
ddr-models-1.15.0 spec/support/shared_examples_for_indexing.rb
ddr-models-1.14.2 spec/support/shared_examples_for_indexing.rb
ddr-models-1.14.1 spec/support/shared_examples_for_indexing.rb
ddr-models-1.14.0 spec/support/shared_examples_for_indexing.rb
ddr-models-1.13.2 spec/support/shared_examples_for_indexing.rb
ddr-models-1.13.1 spec/support/shared_examples_for_indexing.rb
ddr-models-1.13.0 spec/support/shared_examples_for_indexing.rb
ddr-models-1.11.8 spec/support/shared_examples_for_indexing.rb
ddr-models-1.12.3 spec/support/shared_examples_for_indexing.rb
ddr-models-1.11.7 spec/support/shared_examples_for_indexing.rb
ddr-models-1.12.2 spec/support/shared_examples_for_indexing.rb
ddr-models-1.11.6 spec/support/shared_examples_for_indexing.rb
ddr-models-1.12.1 spec/support/shared_examples_for_indexing.rb
ddr-models-1.11.5 spec/support/shared_examples_for_indexing.rb
ddr-models-1.12.0 spec/support/shared_examples_for_indexing.rb