Sha256: 3daa6ff90597e3394c02ecfa545cea311bb631ee666dbf45d1ca9a8fc8f7b7cf

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

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

describe Card::Chunk::QueryReference, "QueryReference" do

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

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

    subject { query_refs.first.name }

    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

14 entries across 14 versions & 1 rubygems

Version Path
card-1.17.4 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.17.3 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.17.2 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.17.1 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.17.0 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.15 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.14 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.13 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.12 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.11 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.10 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.9 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.8 mod/05_standard/spec/chunk/query_reference_spec.rb
card-1.16.7 mod/05_standard/spec/chunk/query_reference_spec.rb