Skip to content

Commit e806c3f

Browse files
authored
Merge pull request #425 from plural/test-tidying
Tidy up test keyword examples for parser.
2 parents 8a16d05 + 1f44bd9 commit e806c3f

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

spec/libraries/search_parser_spec.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
RSpec.describe SearchParser do
77
describe '#keyword' do
88
it 'parses a keyword' do
9-
input = %(t)
9+
input = 'keywordlikestring'
1010
parser = described_class.new.keyword
1111
tree = parser.parse_with_debug(input)
1212
expect(tree).not_to be_nil
1313
end
1414

1515
it 'fails with non-keyword' do
16-
inputs = [%(...), %(1)]
16+
inputs = %w[... 1]
1717
parser = described_class.new.keyword
1818
inputs.each do |i|
1919
expect do
@@ -25,7 +25,7 @@
2525

2626
describe '#operator' do
2727
it 'parses an operator' do
28-
operators = [':', '!', '>', '<', '<=', '>=']
28+
operators = %w[: ! > < <= >=]
2929
parser = described_class.new.operator
3030
operators.each do |o|
3131
tree = parser.parse_with_debug(o)
@@ -34,7 +34,7 @@
3434
end
3535

3636
it 'fails with non-operator' do
37-
inputs = ['a', '?', '&', '(', '-']
37+
inputs = %w[a ? & ( -]
3838
parser = described_class.new.operator
3939
inputs.each do |o|
4040
expect do
@@ -62,7 +62,7 @@
6262
end
6363

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

7474
describe '#value_ors' do
7575
it 'parses combined values' do
76-
values = ['a|b', 'a&b', '(a)', 'a|(b&c)', '(a&b)|(c&d)']
76+
values = %w[a|b a&b (a) a|(b&c) (a&b)|(c&d)]
7777
values.each do |v|
7878
parser = described_class.new.value_ors
7979
tree = parser.parse_with_debug(v)
@@ -85,7 +85,7 @@
8585
describe '#pair' do
8686
it 'parses a pair' do
8787
keywords = %w[a b c]
88-
operators = [':', '!', '>', '<', '<=', '>=']
88+
operators = %w[: ! > < <= >=]
8989
values = ['a', '/.*[^ab]$/', %{(a|"b")&(c|' d ')}]
9090
keywords.each do |k|
9191
operators.each do |o|
@@ -101,14 +101,14 @@
101101

102102
describe '#query' do
103103
it 'parses a query' do
104-
input = %(f:weyland-consortium t!"operation" n<=1)
104+
input = 'f:weyland-consortium t!"operation" n<=1'
105105
parser = described_class.new.query
106106
tree = parser.parse_with_debug(input)
107107
expect(tree).not_to be_nil
108108
end
109109

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

118118
describe '#bare_string' do
119119
it 'parses a bare string' do
120-
input = %(hello-world)
120+
input = 'hello-world'
121121
parser = described_class.new.bare_string
122122
tree = parser.parse_with_debug(input)
123123
expect(tree).not_to be_nil
@@ -126,7 +126,7 @@
126126

127127
describe '#quoted_string' do
128128
it 'parses a quoted string' do
129-
input = %("hello world")
129+
input = '"hello world"'
130130
parser = described_class.new.quoted_string
131131
tree = parser.parse_with_debug(input)
132132
expect(tree).not_to be_nil
@@ -135,35 +135,35 @@
135135

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

144144
it 'parses a bare word' do
145-
input = %( siphon )
145+
input = ' siphon '
146146
parser = described_class.new
147147
tree = parser.parse_with_debug(input)
148148
expect(tree).not_to be_nil
149149
end
150150

151151
it 'parses a quoted word' do
152-
input = %( "sure gamble")
152+
input = ' "sure gamble"'
153153
parser = described_class.new
154154
tree = parser.parse_with_debug(input)
155155
expect(tree).not_to be_nil
156156
end
157157

158158
it 'parses strings' do
159-
input = %( "sure gamble" diversion )
159+
input = ' "sure gamble" diversion '
160160
parser = described_class.new
161161
tree = parser.parse_with_debug(input)
162162
expect(tree).not_to be_nil
163163
end
164164

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

173173
describe '#string' do
174174
it 'parses a string' do
175-
inputs = [%("sure gamble"), %(diversion)]
175+
inputs = ['"sure gamble"', 'diversion']
176176
inputs.each do |s|
177177
parser = described_class.new.string
178178
tree = parser.parse_with_debug(s)

0 commit comments

Comments
 (0)