Sha256: e44464ad56881007e071f8f21ed570208c08e601d720362b451f219890aee5b9

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 KB

Contents

module Ddr::Index
  RSpec.describe Query do

    describe "initialized with attributes" do
      let(:id) { UniqueKeyField.instance }
      let(:foo) { Field.new("foo") }
      let(:spam) { Field.new("spam") }
      let(:filter) { Filter.where(spam=>"eggs") }
      let(:sort_order) { SortOrder.new(field: foo, order: "asc") }
      let(:fields) { [id, foo, spam] }

      subject {
        described_class.new(q: "foo:bar",
                            filters: [filter],
                            fields: fields,
                            sort: sort_order,
                            rows: 50)
      }

      its(:to_s) {
        is_expected.to eq "q=foo%3Abar&fq=spam%3Aeggs&fl=id%2Cfoo%2Cspam&sort=foo+asc&rows=50"
      }
      its(:params) {
        is_expected.to eq({q: "foo:bar", fl: "id,foo,spam", fq: ["spam:eggs"], sort: "foo asc", rows: 50})
      }
    end

    describe "initialized with a block" do
      subject {
        described_class.new do
          q "foo:bar"
          where "spam"=>"eggs"
          fields :id, "foo", "spam"
          asc "foo"
          limit 50
        end
      }

      its(:to_s) {
        is_expected.to eq "q=foo%3Abar&fq=spam%3Aeggs&fl=id%2Cfoo%2Cspam&sort=foo+asc&rows=50"
      }
      its(:params) {
        is_expected.to eq({q: "foo:bar", fl: "id,foo,spam", fq: ["spam:eggs"], sort: "foo asc", rows: 50})
      }
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ddr-models-2.4.12 spec/index/query_spec.rb
ddr-models-2.4.11 spec/index/query_spec.rb
ddr-models-2.4.10 spec/index/query_spec.rb
ddr-models-2.4.9 spec/index/query_spec.rb
ddr-models-2.4.8 spec/index/query_spec.rb
ddr-models-2.4.7 spec/index/query_spec.rb
ddr-models-2.4.6 spec/index/query_spec.rb
ddr-models-2.4.5 spec/index/query_spec.rb
ddr-models-2.4.4 spec/index/query_spec.rb
ddr-models-2.4.3 spec/index/query_spec.rb
ddr-models-2.4.2 spec/index/query_spec.rb
ddr-models-3.0.0.beta.4 spec/index/query_spec.rb
ddr-models-2.4.1 spec/index/query_spec.rb
ddr-models-2.4.0 spec/index/query_spec.rb
ddr-models-2.4.0.rc6 spec/index/query_spec.rb