From 38aea794a999e56625276a5062e971ba7f048068 Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Sun, 15 Mar 2026 21:05:58 +0000 Subject: [PATCH 1/2] Tidy up test keyword examples for parser. --- spec/libraries/search_parser_spec.rb | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/spec/libraries/search_parser_spec.rb b/spec/libraries/search_parser_spec.rb index 1c9ce72..9df44ff 100644 --- a/spec/libraries/search_parser_spec.rb +++ b/spec/libraries/search_parser_spec.rb @@ -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 @@ -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) @@ -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 @@ -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) @@ -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) @@ -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| @@ -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 @@ -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 @@ -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 @@ -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 @@ -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) From 1f44bd9ac9831e32b47b7db0061d833138e1eacd Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Sun, 15 Mar 2026 22:57:30 +0000 Subject: [PATCH 2/2] bah, fix lint i missed --- spec/libraries/search_parser_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/libraries/search_parser_spec.rb b/spec/libraries/search_parser_spec.rb index 9df44ff..bb73b3e 100644 --- a/spec/libraries/search_parser_spec.rb +++ b/spec/libraries/search_parser_spec.rb @@ -13,7 +13,7 @@ end it 'fails with non-keyword' do - inputs = %w(... 1) + inputs = %w[... 1] parser = described_class.new.keyword inputs.each do |i| expect do @@ -25,7 +25,7 @@ describe '#operator' do it 'parses an operator' do - operators = %w(: ! > < <= >=) + operators = %w[: ! > < <= >=] parser = described_class.new.operator operators.each do |o| tree = parser.parse_with_debug(o)