Sha256: df063513c915a2ba53d448f1df49c38335ec6c1f10068d817fe4dc63f6c26494

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

module Ddr::Index
  RSpec.describe CSVQueryResult do

    subject { described_class.new(query) }

    before do
      Item.create(title: ["Testing 1"],
                  identifier: ["test1"],
                  description: ["The process of eliminating errors."])
      Item.create(title: ["Testing 2"],
                  identifier: ["test2"])
      Item.create(title: ["Testing 3"])
    end

    let(:query) {
      Ddr::Index::Query.new do
        fields Ddr::Index::Fields::ID
        fields Ddr::Index::Fields.descmd
      end
    }

    specify {
      expect(subject["title"]).to contain_exactly("Testing 1", "Testing 2", "Testing 3")
      expect(subject["identifier"]).to contain_exactly("test1", "test2", nil)
      expect(subject["description"]).to contain_exactly("The process of eliminating errors.", nil, nil)
      expect(subject["creator"]).to contain_exactly(nil, nil, nil)
      expect(subject.headers).to include("creator")
      expect(subject.to_s).to match(/creator/)
    }

    describe "#delete_empty_columns!" do
      specify {
        subject.delete_empty_columns!
        expect(subject["title"]).to contain_exactly("Testing 1", "Testing 2", "Testing 3")
        expect(subject["identifier"]).to contain_exactly("test1", "test2", nil)
        expect(subject["description"]).to contain_exactly("The process of eliminating errors.", nil, nil)
        expect(subject["creator"]).to contain_exactly(nil, nil, nil)
        expect(subject.headers).to contain_exactly("pid", "title", "identifier", "description")
        expect(subject.to_s).not_to match(/creator/)
      }
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ddr-models-2.6.2 spec/index/csv_query_result_spec.rb
ddr-models-2.6.1 spec/index/csv_query_result_spec.rb
ddr-models-2.6.0 spec/index/csv_query_result_spec.rb
ddr-models-2.6.0.rc4 spec/index/csv_query_result_spec.rb
ddr-models-2.6.0.rc3 spec/index/csv_query_result_spec.rb
ddr-models-2.6.0.rc2 spec/index/csv_query_result_spec.rb
ddr-models-2.6.0.rc1 spec/index/csv_query_result_spec.rb
ddr-models-2.5.3 spec/index/csv_query_result_spec.rb
ddr-models-2.5.2 spec/index/csv_query_result_spec.rb
ddr-models-2.5.1 spec/index/csv_query_result_spec.rb
ddr-models-2.5.0 spec/index/csv_query_result_spec.rb
ddr-models-2.5.0.rc1 spec/index/csv_query_result_spec.rb
ddr-models-2.4.16 spec/index/csv_query_result_spec.rb
ddr-models-2.4.15 spec/index/csv_query_result_spec.rb
ddr-models-2.4.14 spec/index/csv_query_result_spec.rb
ddr-models-2.4.13 spec/index/csv_query_result_spec.rb