Sha256: 6899eff7c28a96ea88cc05438e5a8b633bfc96a2b86848d31c3356bf4b71155f

Contents?: true

Size: 1.32 KB

Versions: 47

Compression:

Stored size: 1.32 KB

Contents

# -*- encoding : utf-8 -*-

describe Card::Content::Chunk::QueryReference, "QueryReference" do
  context "syntax parsing" do
    before do
      @class = Card::Content::Chunk::QueryReference
    end

    subject { query_refs.first.name }

    let :query_refs do
      content = Card::Content.new @content, Card.new(type: "Search")
      content.find_chunks(Card::Content::Chunk::QueryReference)
    end

    it "handles simple search" do
      @content = '{"name":"Waldo"}'
      is_expected.to eq "Waldo"
    end

    it "handles operators" do
      @content = '{"name":["eq","Waldo"]}'
      is_expected.to eq "Waldo"
    end

    it "handles multiple values for operators" do
      @content = '{"name":["in","Where","Waldo"]}'
      expect(query_refs[1].name).to eq "Waldo"
    end

    it "handles plus attributes" do
      @content = '{"right_plus":["Waldo",{"content":"here"}]}'
      is_expected.to eq "Waldo"
    end

    it "handles nested query structures" do
      @content = '{"any":{"content":"Where", ' \
                 '"right_plus":["is",{"name":"Waldo"}]}}'
      expect(query_refs[0].name).to eq "Where"
      expect(query_refs[1].name).to eq "is"
      expect(query_refs[2].name).to eq "Waldo"
    end

    it "handles contextual names" do
      @content = '{"name":"_+Waldo"}'
      is_expected.to eq "_+Waldo"
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
card-1.99.6 mod/core/spec/chunk/query_reference_spec.rb
card-1.99.5 mod/core/spec/chunk/query_reference_spec.rb
card-1.99.4 mod/core/spec/chunk/query_reference_spec.rb
card-1.99.3 mod/core/spec/chunk/query_reference_spec.rb
card-1.99.2 mod/core/spec/chunk/query_reference_spec.rb
card-1.99.1 mod/core/spec/chunk/query_reference_spec.rb
card-1.99.0 mod/core/spec/chunk/query_reference_spec.rb
card-1.98.3 mod/core/spec/chunk/query_reference_spec.rb
card-1.98.2 mod/core/spec/chunk/query_reference_spec.rb
card-1.98.1 mod/core/spec/chunk/query_reference_spec.rb
card-1.98.0 mod/core/spec/chunk/query_reference_spec.rb
card-1.97.0.1 mod/core/spec/chunk/query_reference_spec.rb
card-1.97.0 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.8 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.7 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.6 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.5 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.4 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.3 mod/standard/spec/content/chunk/query_reference_spec.rb
card-1.96.2 mod/standard/spec/content/chunk/query_reference_spec.rb