|
6 | 6 | RSpec.describe SearchParser do |
7 | 7 | describe '#keyword' do |
8 | 8 | it 'parses a keyword' do |
9 | | - input = %(t) |
| 9 | + input = 'keywordlikestring' |
10 | 10 | parser = described_class.new.keyword |
11 | 11 | tree = parser.parse_with_debug(input) |
12 | 12 | expect(tree).not_to be_nil |
13 | 13 | end |
14 | 14 |
|
15 | 15 | it 'fails with non-keyword' do |
16 | | - inputs = [%(...), %(1)] |
| 16 | + inputs = %w[... 1] |
17 | 17 | parser = described_class.new.keyword |
18 | 18 | inputs.each do |i| |
19 | 19 | expect do |
|
25 | 25 |
|
26 | 26 | describe '#operator' do |
27 | 27 | it 'parses an operator' do |
28 | | - operators = [':', '!', '>', '<', '<=', '>='] |
| 28 | + operators = %w[: ! > < <= >=] |
29 | 29 | parser = described_class.new.operator |
30 | 30 | operators.each do |o| |
31 | 31 | tree = parser.parse_with_debug(o) |
|
34 | 34 | end |
35 | 35 |
|
36 | 36 | it 'fails with non-operator' do |
37 | | - inputs = ['a', '?', '&', '(', '-'] |
| 37 | + inputs = %w[a ? & ( -] |
38 | 38 | parser = described_class.new.operator |
39 | 39 | inputs.each do |o| |
40 | 40 | expect do |
|
62 | 62 | end |
63 | 63 |
|
64 | 64 | it 'parses a quote value' do |
65 | | - values = [%("double"), "'single'", %("double quotes"), %('single quotes')] |
| 65 | + values = ['"double"', "'single'", '"double quotes"', "'single quotes'"] |
66 | 66 | values.each do |v| |
67 | 67 | parser = described_class.new.values |
68 | 68 | tree = parser.parse_with_debug(v) |
|
73 | 73 |
|
74 | 74 | describe '#value_ors' do |
75 | 75 | 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)] |
77 | 77 | values.each do |v| |
78 | 78 | parser = described_class.new.value_ors |
79 | 79 | tree = parser.parse_with_debug(v) |
|
85 | 85 | describe '#pair' do |
86 | 86 | it 'parses a pair' do |
87 | 87 | keywords = %w[a b c] |
88 | | - operators = [':', '!', '>', '<', '<=', '>='] |
| 88 | + operators = %w[: ! > < <= >=] |
89 | 89 | values = ['a', '/.*[^ab]$/', %{(a|"b")&(c|' d ')}] |
90 | 90 | keywords.each do |k| |
91 | 91 | operators.each do |o| |
|
101 | 101 |
|
102 | 102 | describe '#query' do |
103 | 103 | it 'parses a query' do |
104 | | - input = %(f:weyland-consortium t!"operation" n<=1) |
| 104 | + input = 'f:weyland-consortium t!"operation" n<=1' |
105 | 105 | parser = described_class.new.query |
106 | 106 | tree = parser.parse_with_debug(input) |
107 | 107 | expect(tree).not_to be_nil |
108 | 108 | end |
109 | 109 |
|
110 | 110 | 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' |
112 | 112 | parser = described_class.new.query |
113 | 113 | tree = parser.parse_with_debug(input) |
114 | 114 | expect(tree).not_to be_nil |
|
117 | 117 |
|
118 | 118 | describe '#bare_string' do |
119 | 119 | it 'parses a bare string' do |
120 | | - input = %(hello-world) |
| 120 | + input = 'hello-world' |
121 | 121 | parser = described_class.new.bare_string |
122 | 122 | tree = parser.parse_with_debug(input) |
123 | 123 | expect(tree).not_to be_nil |
|
126 | 126 |
|
127 | 127 | describe '#quoted_string' do |
128 | 128 | it 'parses a quoted string' do |
129 | | - input = %("hello world") |
| 129 | + input = '"hello world"' |
130 | 130 | parser = described_class.new.quoted_string |
131 | 131 | tree = parser.parse_with_debug(input) |
132 | 132 | expect(tree).not_to be_nil |
|
135 | 135 |
|
136 | 136 | describe '#root parser' do |
137 | 137 | it 'parses a query' do |
138 | | - input = %(f:weyland-consortium t!"operation" n<=1) |
| 138 | + input = 'f:weyland-consortium t!"operation" n<=1' |
139 | 139 | parser = described_class.new |
140 | 140 | tree = parser.parse_with_debug(input) |
141 | 141 | expect(tree).not_to be_nil |
142 | 142 | end |
143 | 143 |
|
144 | 144 | it 'parses a bare word' do |
145 | | - input = %( siphon ) |
| 145 | + input = ' siphon ' |
146 | 146 | parser = described_class.new |
147 | 147 | tree = parser.parse_with_debug(input) |
148 | 148 | expect(tree).not_to be_nil |
149 | 149 | end |
150 | 150 |
|
151 | 151 | it 'parses a quoted word' do |
152 | | - input = %( "sure gamble") |
| 152 | + input = ' "sure gamble"' |
153 | 153 | parser = described_class.new |
154 | 154 | tree = parser.parse_with_debug(input) |
155 | 155 | expect(tree).not_to be_nil |
156 | 156 | end |
157 | 157 |
|
158 | 158 | it 'parses strings' do |
159 | | - input = %( "sure gamble" diversion ) |
| 159 | + input = ' "sure gamble" diversion ' |
160 | 160 | parser = described_class.new |
161 | 161 | tree = parser.parse_with_debug(input) |
162 | 162 | expect(tree).not_to be_nil |
163 | 163 | end |
164 | 164 |
|
165 | 165 | 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 ' |
167 | 167 | parser = described_class.new |
168 | 168 | tree = parser.parse_with_debug(input) |
169 | 169 | expect(tree).not_to be_nil |
|
172 | 172 |
|
173 | 173 | describe '#string' do |
174 | 174 | it 'parses a string' do |
175 | | - inputs = [%("sure gamble"), %(diversion)] |
| 175 | + inputs = ['"sure gamble"', 'diversion'] |
176 | 176 | inputs.each do |s| |
177 | 177 | parser = described_class.new.string |
178 | 178 | tree = parser.parse_with_debug(s) |
|
0 commit comments