Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions spec/libraries/search_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
RSpec.describe SearchParser do
describe '#keyword' do
it 'parses a keyword' do
input = %(t)
input = 'keywordlikestring'
parser = described_class.new.keyword
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
end

it 'fails with non-keyword' do
inputs = [%(...), %(1)]
inputs = %w[... 1]
parser = described_class.new.keyword
inputs.each do |i|
expect do
Expand All @@ -25,7 +25,7 @@

describe '#operator' do
it 'parses an operator' do
operators = [':', '!', '>', '<', '<=', '>=']
operators = %w[: ! > < <= >=]
parser = described_class.new.operator
operators.each do |o|
tree = parser.parse_with_debug(o)
Expand All @@ -34,7 +34,7 @@
end

it 'fails with non-operator' do
inputs = ['a', '?', '&', '(', '-']
inputs = %w[a ? & ( -]
parser = described_class.new.operator
inputs.each do |o|
expect do
Expand Down Expand Up @@ -62,7 +62,7 @@
end

it 'parses a quote value' do
values = [%("double"), "'single'", %("double quotes"), %('single quotes')]
values = ['"double"', "'single'", '"double quotes"', "'single quotes'"]
values.each do |v|
parser = described_class.new.values
tree = parser.parse_with_debug(v)
Expand All @@ -73,7 +73,7 @@

describe '#value_ors' do
it 'parses combined values' do
values = ['a|b', 'a&b', '(a)', 'a|(b&c)', '(a&b)|(c&d)']
values = %w[a|b a&b (a) a|(b&c) (a&b)|(c&d)]
values.each do |v|
parser = described_class.new.value_ors
tree = parser.parse_with_debug(v)
Expand All @@ -85,7 +85,7 @@
describe '#pair' do
it 'parses a pair' do
keywords = %w[a b c]
operators = [':', '!', '>', '<', '<=', '>=']
operators = %w[: ! > < <= >=]
values = ['a', '/.*[^ab]$/', %{(a|"b")&(c|' d ')}]
keywords.each do |k|
operators.each do |o|
Expand All @@ -101,14 +101,14 @@

describe '#query' do
it 'parses a query' do
input = %(f:weyland-consortium t!"operation" n<=1)
input = 'f:weyland-consortium t!"operation" n<=1'
parser = described_class.new.query
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
end

it 'parses a query and some words' do
input = %(a b test run f:weyland-consortium t!"operation" n<=1)
input = 'a b test run f:weyland-consortium t!"operation" n<=1'
parser = described_class.new.query
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
Expand All @@ -117,7 +117,7 @@

describe '#bare_string' do
it 'parses a bare string' do
input = %(hello-world)
input = 'hello-world'
parser = described_class.new.bare_string
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
Expand All @@ -126,7 +126,7 @@

describe '#quoted_string' do
it 'parses a quoted string' do
input = %("hello world")
input = '"hello world"'
parser = described_class.new.quoted_string
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
Expand All @@ -135,35 +135,35 @@

describe '#root parser' do
it 'parses a query' do
input = %(f:weyland-consortium t!"operation" n<=1)
input = 'f:weyland-consortium t!"operation" n<=1'
parser = described_class.new
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
end

it 'parses a bare word' do
input = %( siphon )
input = ' siphon '
parser = described_class.new
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
end

it 'parses a quoted word' do
input = %( "sure gamble")
input = ' "sure gamble"'
parser = described_class.new
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
end

it 'parses strings' do
input = %( "sure gamble" diversion )
input = ' "sure gamble" diversion '
parser = described_class.new
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
end

it 'parses a query and some words' do
input = %("bean" f:weyland-consortium t!"operation" royalties n<=1 )
input = '"bean" f:weyland-consortium t!"operation" royalties n<=1 '
parser = described_class.new
tree = parser.parse_with_debug(input)
expect(tree).not_to be_nil
Expand All @@ -172,7 +172,7 @@

describe '#string' do
it 'parses a string' do
inputs = [%("sure gamble"), %(diversion)]
inputs = ['"sure gamble"', 'diversion']
inputs.each do |s|
parser = described_class.new.string
tree = parser.parse_with_debug(s)
Expand Down
Loading