Sha256: cc4e481a7ec2194d4f4a27e36117fd21c44825fd3916dd96bcead55500040f31

Contents?: true

Size: 1.59 KB

Versions: 10

Compression:

Stored size: 1.59 KB

Contents

module Ddr::Index
  RSpec.describe CSVQueryResult do

    subject { described_class.new(query) }

    before do
      Item.create(dc_title: ["Testing 1"],
                  dc_identifier: ["test1"],
                  dc_description: ["The process of eliminating errors."])
      Item.create(dc_title: ["Testing 2"],
                  dc_identifier: ["test2"])
      Item.create(dc_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

10 entries across 10 versions & 1 rubygems

Version Path
ddr-models-3.0.8 spec/index/csv_query_result_spec.rb
ddr-models-3.0.7 spec/index/csv_query_result_spec.rb
ddr-models-3.0.6 spec/index/csv_query_result_spec.rb
ddr-models-3.0.5 spec/index/csv_query_result_spec.rb
ddr-models-3.0.4 spec/index/csv_query_result_spec.rb
ddr-models-3.0.3 spec/index/csv_query_result_spec.rb
ddr-models-3.0.2 spec/index/csv_query_result_spec.rb
ddr-models-3.0.1 spec/index/csv_query_result_spec.rb
ddr-models-3.0.0 spec/index/csv_query_result_spec.rb
ddr-models-3.0.0.rc6 spec/index/csv_query_result_spec.rb