Sha256: ce679808d5ff30b6e0f4bd82fcce52a6f19075a1eeed6232888bc4f52d09ea6c

Contents?: true

Size: 1.58 KB

Versions: 38

Compression:

Stored size: 1.58 KB

Contents

module Ddr::Models
  RSpec.describe YearFacet do

    subject { described_class.new(obj) }
    let(:obj) { Item.new }
    before { obj.date = [ date ] }

    describe "splitting on semicolons" do
      let(:date) { "1935; 1936; 1937; 1938" }
      its(:values) { is_expected.to eq([1935, 1936, 1937, 1938]) }
    end

    describe "year range" do
      %w( 1935-1940 1935/1940 ).each do |value|
        describe value do
          let(:date) { value }
          its(:values) { is_expected.to eq((1935..1940).to_a) }
        end
      end
    end

    describe "in decade" do
      %w( 192x 192X 192? 192- 192-? ).each do |value|
        describe value do
          let(:date) { value }
          its(:values) { is_expected.to eq((1920..1929).to_a) }
        end
      end
    end

    describe "in century -- YYxx (19xx)" do
      let(:date) { "19xx" }
      its(:values) { is_expected.to eq((1900..1999).to_a) }
    end

    describe "decade" do
      %w( 1920s 1920s? ).each do |value|
        describe value do
          let(:date) { value }
          its(:values) { is_expected.to eq((1920..1929).to_a) }
        end
      end
    end

    describe "year + month" do
      %w( 2010-01 2010/01 ).each do |value|
        describe value do
          let(:date) { value }
          its(:values) { is_expected.to eq([2010]) }
        end
      end
    end

    describe "between" do
      let(:date) { "Between 1965 and 1968" }
      its(:values) { is_expected.to eq((1965..1968).to_a) }
    end

    describe "year" do
      let(:date) { "1965" }
      its(:values) { is_expected.to eq([1965]) }
    end

  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
ddr-models-2.5.3 spec/models/year_facet_spec.rb
ddr-models-2.5.2 spec/models/year_facet_spec.rb
ddr-models-2.5.1 spec/models/year_facet_spec.rb
ddr-models-2.5.0 spec/models/year_facet_spec.rb
ddr-models-2.5.0.rc1 spec/models/year_facet_spec.rb
ddr-models-2.4.16 spec/models/year_facet_spec.rb
ddr-models-2.4.15 spec/models/year_facet_spec.rb
ddr-models-2.4.14 spec/models/year_facet_spec.rb
ddr-models-2.4.13 spec/models/year_facet_spec.rb
ddr-models-2.4.12 spec/models/year_facet_spec.rb
ddr-models-2.4.11 spec/models/year_facet_spec.rb
ddr-models-2.4.10 spec/models/year_facet_spec.rb
ddr-models-2.4.9 spec/models/year_facet_spec.rb
ddr-models-2.4.8 spec/models/year_facet_spec.rb
ddr-models-2.4.7 spec/models/year_facet_spec.rb
ddr-models-2.4.6 spec/models/year_facet_spec.rb
ddr-models-2.4.5 spec/models/year_facet_spec.rb
ddr-models-2.4.4 spec/models/year_facet_spec.rb
ddr-models-2.4.3 spec/models/year_facet_spec.rb
ddr-models-2.4.2 spec/models/year_facet_spec.rb