Sha256: 76ea1ce1f8d21d4f221e9be475af1471d5aaa6a75d7926ee5f0ba36af9c274eb

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'druid/elements'

describe Druid::Elements::OrderedList do
  let(:ol) { Druid::Elements::OrderedList }

  describe "interface" do
    let(:ol_element) { double('ol_element').as_null_object }
    let(:li_element) { double('li_element') }

    it "should register as tag_name :ol" do
      expect(Druid::Elements.element_class_for(:ol)).to be Druid::Elements::OrderedList
    end

    context "for sub methods" do
      before(:each) do
        allow(ol_element).to receive(:tag_name).and_return(:ol)
      end
      let(:ol) {  ol = Druid::Elements::OrderedList.new(ol_element) }

      it "should return a list item when indexed" do
        allow(ol_element).to receive(:children).and_return([ol_element, ol_element])
        ol[1]
      end

      it "should know how many list items it contains" do
        allow(ol_element).to receive(:children).and_return([ol_element])
        expect(ol.items).to eql 1
      end

      it "should iterate over the list items" do
        expect(ol).to receive(:list_items).and_return(Array.new(5, ol_element))
        expect(ol.items).to eql 5
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
druid-s-1.0.0 spec/druid/elements/ordered_list_spec.rb
druid-ts-1.2.6 spec/druid/elements/ordered_list_spec.rb
druid-ts-1.2.5 spec/druid/elements/ordered_list_spec.rb