Sha256: 4dc1f5a24dd8d7d91b821c252e7b31da90a65b8cb0171fe13712af629734951d

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'lenjador/preprocessors/json_pointer_trie'

RSpec.describe Lenjador::Preprocessors::JSONPointerTrie do
  let(:trie) { described_class.new }

  describe '#includes?' do
    it 'returns true for empty prefix' do
      expect(trie).to include('')
    end

    it 'returns true if trie contains requested prefix or value itself' do
      trie.insert('/data/nested/key')

      expect(trie).to include('/data')
      expect(trie).to include('/data/nested')
      expect(trie).to include('/data/nested/key')
    end

    it 'returns false if trie does not contain requested prefix or value' do
      trie.insert('/data/nested/key')

      expect(trie).not_to include('/bad_data')
      expect(trie).not_to include('/data/bad_nested')
      expect(trie).not_to include('/data/nested/bad_key')
    end

    it 'returns true if trie contains requested prefix under wildcard' do
      trie.insert('/data/~/key')

      expect(trie).to include('/data/arbitrary_key/key')
      expect(trie).to include('/data/another_key/key')
      expect(trie).not_to include('/data/arbitrary_key/bad_nested_key')
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lenjador-2.3.1 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.3.0 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.2.2 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.2.1 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.2.0 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.1.0 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.0.1 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-2.0.0 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-1.4.0 spec/lenjador/preprocessors/json_pointer_trie_spec.rb
lenjador-1.3.0 spec/lenjador/preprocessors/json_pointer_trie_spec.rb