synvert-core 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -4
  3. data/CHANGELOG.md +16 -0
  4. data/Gemfile +0 -3
  5. data/Guardfile +0 -9
  6. data/README.md +30 -12
  7. data/Rakefile +1 -15
  8. data/lib/synvert/core/engine/erb.rb +1 -1
  9. data/lib/synvert/core/engine.rb +1 -1
  10. data/lib/synvert/core/node_ext.rb +0 -466
  11. data/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb +20 -17
  12. data/lib/synvert/core/rewriter/condition/if_exist_condition.rb +1 -1
  13. data/lib/synvert/core/rewriter/condition/unless_exist_condition.rb +1 -1
  14. data/lib/synvert/core/rewriter/instance.rb +89 -135
  15. data/lib/synvert/core/rewriter/scope/query_scope.rb +2 -2
  16. data/lib/synvert/core/rewriter/scope/within_scope.rb +4 -4
  17. data/lib/synvert/core/rewriter.rb +0 -10
  18. data/lib/synvert/core/version.rb +1 -1
  19. data/lib/synvert/core.rb +4 -6
  20. data/spec/synvert/core/engine/erb_spec.rb +3 -3
  21. data/spec/synvert/core/node_ext_spec.rb +0 -795
  22. data/spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb +21 -1
  23. data/spec/synvert/core/rewriter/instance_spec.rb +49 -112
  24. data/spec/synvert/core/rewriter/scope/goto_scope_spec.rb +1 -4
  25. data/spec/synvert/core/rewriter/scope/query_scope_spec.rb +8 -4
  26. data/spec/synvert/core/rewriter/scope/within_scope_spec.rb +1 -4
  27. data/synvert-core-ruby.gemspec +4 -2
  28. metadata +44 -61
  29. data/lib/synvert/core/array_ext.rb +0 -48
  30. data/lib/synvert/core/node_query/compiler/array.rb +0 -34
  31. data/lib/synvert/core/node_query/compiler/attribute.rb +0 -39
  32. data/lib/synvert/core/node_query/compiler/attribute_list.rb +0 -24
  33. data/lib/synvert/core/node_query/compiler/boolean.rb +0 -23
  34. data/lib/synvert/core/node_query/compiler/comparable.rb +0 -86
  35. data/lib/synvert/core/node_query/compiler/dynamic_attribute.rb +0 -51
  36. data/lib/synvert/core/node_query/compiler/expression.rb +0 -58
  37. data/lib/synvert/core/node_query/compiler/float.rb +0 -23
  38. data/lib/synvert/core/node_query/compiler/identifier.rb +0 -41
  39. data/lib/synvert/core/node_query/compiler/integer.rb +0 -23
  40. data/lib/synvert/core/node_query/compiler/invalid_operator_error.rb +0 -7
  41. data/lib/synvert/core/node_query/compiler/nil.rb +0 -23
  42. data/lib/synvert/core/node_query/compiler/parse_error.rb +0 -7
  43. data/lib/synvert/core/node_query/compiler/regexp.rb +0 -37
  44. data/lib/synvert/core/node_query/compiler/selector.rb +0 -138
  45. data/lib/synvert/core/node_query/compiler/simple_selector.rb +0 -29
  46. data/lib/synvert/core/node_query/compiler/string.rb +0 -23
  47. data/lib/synvert/core/node_query/compiler/symbol.rb +0 -23
  48. data/lib/synvert/core/node_query/compiler.rb +0 -25
  49. data/lib/synvert/core/node_query/lexer.rex +0 -108
  50. data/lib/synvert/core/node_query/lexer.rex.rb +0 -321
  51. data/lib/synvert/core/node_query/parser.racc.rb +0 -322
  52. data/lib/synvert/core/node_query/parser.y +0 -62
  53. data/lib/synvert/core/node_query.rb +0 -37
  54. data/lib/synvert/core/rewriter/action/append_action.rb +0 -28
  55. data/lib/synvert/core/rewriter/action/delete_action.rb +0 -32
  56. data/lib/synvert/core/rewriter/action/insert_action.rb +0 -34
  57. data/lib/synvert/core/rewriter/action/insert_after_action.rb +0 -22
  58. data/lib/synvert/core/rewriter/action/prepend_action.rb +0 -44
  59. data/lib/synvert/core/rewriter/action/remove_action.rb +0 -53
  60. data/lib/synvert/core/rewriter/action/replace_action.rb +0 -33
  61. data/lib/synvert/core/rewriter/action/replace_with_action.rb +0 -36
  62. data/lib/synvert/core/rewriter/action/wrap_action.rb +0 -37
  63. data/lib/synvert/core/rewriter/action.rb +0 -102
  64. data/spec/synvert/core/node_query/lexer_spec.rb +0 -640
  65. data/spec/synvert/core/node_query/parser_spec.rb +0 -382
  66. data/spec/synvert/core/rewriter/action/append_action_spec.rb +0 -70
  67. data/spec/synvert/core/rewriter/action/delete_action_spec.rb +0 -26
  68. data/spec/synvert/core/rewriter/action/insert_action_spec.rb +0 -70
  69. data/spec/synvert/core/rewriter/action/insert_after_action_spec.rb +0 -26
  70. data/spec/synvert/core/rewriter/action/prepend_action_spec.rb +0 -175
  71. data/spec/synvert/core/rewriter/action/remove_action_spec.rb +0 -26
  72. data/spec/synvert/core/rewriter/action/replace_action_spec.rb +0 -28
  73. data/spec/synvert/core/rewriter/action/replace_with_action_spec.rb +0 -59
  74. data/spec/synvert/core/rewriter/action/wrap_action_spec.rb +0 -31
  75. data/spec/synvert/core/rewriter/action_spec.rb +0 -14
@@ -1,382 +0,0 @@
1
- require 'spec_helper'
2
-
3
- def assert_parser(source)
4
- expect(parser.parse(source).to_s).to eq source
5
- end
6
-
7
- module Synvert::Core::NodeQuery
8
- RSpec.describe Parser do
9
- let(:parser) { described_class.new }
10
-
11
- describe '#toString' do
12
- it 'parses one selector' do
13
- source = '.send[message=:create]'
14
- assert_parser(source)
15
- end
16
-
17
- it 'parses two selectors' do
18
- source = '.class[name=Synvert] .def[name="foobar"]'
19
- assert_parser(source)
20
- end
21
-
22
- it 'parses three selectors' do
23
- source = '.class[name=Synvert] .def[name="foobar"] .send[message=create]'
24
- assert_parser(source)
25
- end
26
-
27
- it 'parses child selector' do
28
- source = '.class[name=Synvert] > .def[name="foobar"]'
29
- assert_parser(source)
30
- end
31
-
32
- it 'parses scope' do
33
- source = '.block <body> > .send'
34
- assert_parser(source)
35
- end
36
-
37
- it 'parses :first-child' do
38
- source = '.class .def:first-child'
39
- assert_parser(source)
40
- end
41
-
42
- it 'parses :last-child' do
43
- source = '.class .def:last-child'
44
- assert_parser(source)
45
- end
46
-
47
- it 'parses :nth-child(n)' do
48
- source = '.class .def:nth-child(2)'
49
- assert_parser(source)
50
- end
51
-
52
- it 'parses :nth-last-child(n)' do
53
- source = '.class .def:nth-last-child(2)'
54
- assert_parser(source)
55
- end
56
-
57
- it 'parses :has selector' do
58
- source = '.class:has(> .def)'
59
- assert_parser(source)
60
- end
61
-
62
- it 'parses :not_has selector' do
63
- source = '.class:not_has(> .def)'
64
- assert_parser(source)
65
- end
66
-
67
- it 'parses root :has selector' do
68
- source = ':has(.def)'
69
- assert_parser(source)
70
- end
71
-
72
- it 'parses multiple attributes' do
73
- source = '.send[receiver=nil][message=:create]'
74
- assert_parser(source)
75
- end
76
-
77
- it 'parses nested attributes' do
78
- source = '.send[receiver.message=:create]'
79
- assert_parser(source)
80
- end
81
-
82
- it 'parses selector value' do
83
- source = '.send[receiver=.send[message=:create]]'
84
- assert_parser(source)
85
- end
86
-
87
- it 'parses start with operator' do
88
- source = '.def[name^=synvert]'
89
- assert_parser(source)
90
- end
91
-
92
- it 'parses end with operator' do
93
- source = '.def[name$=synvert]'
94
- assert_parser(source)
95
- end
96
-
97
- it 'parses contain operator' do
98
- source = '.def[name*=synvert]'
99
- assert_parser(source)
100
- end
101
-
102
- it 'parses not equal operator' do
103
- source = '.send[receiver=.send[message!=:create]]'
104
- assert_parser(source)
105
- end
106
-
107
- it 'parses greater than operator' do
108
- source = '.send[receiver=.send[arguments.size>1]]'
109
- assert_parser(source)
110
- end
111
-
112
- it 'parses greater than or equal operator' do
113
- source = '.send[receiver=.send[arguments.size>=1]]'
114
- assert_parser(source)
115
- end
116
-
117
- it 'parses less than operator' do
118
- source = '.send[receiver=.send[arguments.size<1]]'
119
- assert_parser(source)
120
- end
121
-
122
- it 'parses less than or equal operator' do
123
- source = '.send[receiver=.send[arguments.size<=1]]'
124
- assert_parser(source)
125
- end
126
-
127
- it 'parses in operator' do
128
- source = '.def[name in (foo bar)]'
129
- assert_parser(source)
130
- end
131
-
132
- it 'parses not_in operator' do
133
- source = '.def[name not in (foo bar)]'
134
- assert_parser(source)
135
- end
136
-
137
- it 'parses includes operator' do
138
- source = '.def[arguments includes &block]'
139
- assert_parser(source)
140
- end
141
-
142
- it 'parses empty string' do
143
- source = '.send[arguments.first=""]'
144
- assert_parser(source)
145
- end
146
-
147
- it 'parses []=' do
148
- source = '.send[message=[]=]'
149
- assert_parser(source)
150
- end
151
-
152
- it 'parses :[]' do
153
- source = '.send[message=:[]]'
154
- assert_parser(source)
155
- end
156
- end
157
-
158
- describe '#query_nodes' do
159
- let(:node) {
160
- parse(<<~EOS)
161
- class Synvert
162
- def foo
163
- FactoryBot.create(:user, name: 'foo')
164
- end
165
-
166
- def bar
167
- FactoryBot.create(:user, name: 'bar')
168
- end
169
-
170
- def foobar(a, b)
171
- { a: a, b: b }
172
- arr[index]
173
- arr[index] = value
174
- nil?
175
- call('')
176
- end
177
- end
178
- EOS
179
- }
180
-
181
- let(:test_node) {
182
- parse(<<~EOS)
183
- RSpec.describe Synvert do
184
- end
185
- EOS
186
- }
187
-
188
- it 'matches class node' do
189
- expression = parser.parse('.class[name=Synvert]')
190
- expect(expression.query_nodes(node)).to eq [node]
191
- end
192
-
193
- it 'matches def node' do
194
- expression = parser.parse('.def')
195
- expect(expression.query_nodes(node)).to eq node.body
196
- end
197
-
198
- it 'matches first def node' do
199
- expression = parser.parse('.def:first-child')
200
- expect(expression.query_nodes(node)).to eq [node.body.first]
201
- end
202
-
203
- it 'matches nested first node' do
204
- expression = parser.parse('.def[arguments.size=0] .send:first-child')
205
- expect(expression.query_nodes(node)).to eq [node.body.first.body.first, node.body.second.body.first]
206
- end
207
-
208
- it 'matches last def node' do
209
- expression = parser.parse('.def:last-child')
210
- expect(expression.query_nodes(node)).to eq [node.body.last]
211
- end
212
-
213
- it 'matches nth-child node' do
214
- expression = parser.parse('.def:nth-child(2)')
215
- expect(expression.query_nodes(node)).to eq [node.body.second]
216
- end
217
-
218
- it 'matches nth-last-child node' do
219
- expression = parser.parse('.def:nth-last-child(2)')
220
- expect(expression.query_nodes(node)).to eq [node.body[-2]]
221
- end
222
-
223
- it 'matches start with' do
224
- expression = parser.parse('.def[name^=foo]')
225
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.last]
226
- end
227
-
228
- it 'matches end with' do
229
- expression = parser.parse('.def[name$=bar]')
230
- expect(expression.query_nodes(node)).to eq [node.body.second, node.body.last]
231
- end
232
-
233
- it 'matches contain' do
234
- expression = parser.parse('.def[name*=oob]')
235
- expect(expression.query_nodes(node)).to eq [node.body.last]
236
- end
237
-
238
- it 'matches not equal' do
239
- expression = parser.parse('.def[name!=foobar]')
240
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.second]
241
- end
242
-
243
- it 'matches in' do
244
- expression = parser.parse('.def[name IN (foo bar)]')
245
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.second]
246
- end
247
-
248
- it 'matches not in' do
249
- expression = parser.parse('.def[name NOT IN (foo bar)]')
250
- expect(expression.query_nodes(node)).to eq [node.body.last]
251
- end
252
-
253
- it 'matches includes' do
254
- expression = parser.parse('.def[arguments INCLUDES a]')
255
- expect(expression.query_nodes(node)).to eq [node.body.last]
256
- end
257
-
258
- it 'matches equal array' do
259
- expression = parser.parse('.def[arguments=(a b)]')
260
- expect(expression.query_nodes(node)).to eq [node.body.last]
261
-
262
- expression = parser.parse('.def[arguments=(b a)]')
263
- expect(expression.query_nodes(node)).to eq []
264
- end
265
-
266
- it 'matches not equal array' do
267
- expression = parser.parse('.def[arguments!=(a b)]')
268
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.second]
269
-
270
- expression = parser.parse('.def[arguments!=(b a)]')
271
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.second, node.body.last]
272
- end
273
-
274
- it 'matches descendant node' do
275
- expression = parser.parse('.class .send[message=:create]')
276
- expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
277
- end
278
-
279
- it 'matches three level descendant node' do
280
- expression = parser.parse('.class .def .send[message=:create]')
281
- expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
282
- end
283
-
284
- it 'matches child node' do
285
- expression = parser.parse('.def > .send[message=:create]')
286
- expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
287
- end
288
-
289
- it 'matches next sibling node' do
290
- expression = parser.parse('.def[name=foo] + .def[name=bar]')
291
- expect(expression.query_nodes(node)).to eq [node.body.second]
292
- end
293
-
294
- it 'matches sebsequent sibling node' do
295
- expression = parser.parse('.def[name=foo] ~ .def[name=foobar]')
296
- expect(expression.query_nodes(node)).to eq [node.body.last]
297
- end
298
-
299
- it 'matches goto scope' do
300
- expression = parser.parse('.def <body> > .send[message=:create]')
301
- expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
302
-
303
- expression = parser.parse('.def <body> .send[message=:create]')
304
- expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
305
- end
306
-
307
- it 'matches multiple goto scope' do
308
- expression = parser.parse('.block <caller.arguments> .const[name=Synvert]')
309
- expect(expression.query_nodes(test_node)).to eq [test_node.caller.arguments.first]
310
- end
311
-
312
- it 'matches has selector' do
313
- expression = parser.parse('.def:has(> .send[receiver=FactoryBot])')
314
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.second]
315
- end
316
-
317
- it 'matches not_has selector' do
318
- expression = parser.parse('.def:not_has(> .send[receiver=FactoryBot])')
319
- expect(expression.query_nodes(node)).to eq [node.body.last]
320
- end
321
-
322
- it 'matches root has selector' do
323
- expression = parser.parse(':has(.def[name=foobar])')
324
- expect(expression.query_nodes(node)).to eq [node]
325
- end
326
-
327
- it 'matches arguments.size' do
328
- expression = parser.parse('.def .send[arguments.size=2]')
329
- expect(expression.query_nodes(node)).to eq [
330
- node.body.first.body.last,
331
- node.body.second.body.last,
332
- node.body.third.body.third
333
- ]
334
- expression = parser.parse('.def .send[arguments.size>2]')
335
- expect(expression.query_nodes(node)).to eq []
336
- expression = parser.parse('.def .send[arguments.size>=2]')
337
- expect(expression.query_nodes(node)).to eq [
338
- node.body.first.body.last,
339
- node.body.second.body.last,
340
- node.body.third.body.third
341
- ]
342
- end
343
-
344
- it 'matches arguments' do
345
- expression = parser.parse('.send[arguments.size=2][arguments.first=.sym][arguments.last=.hash]')
346
- expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
347
- end
348
-
349
- it 'matches regexp value' do
350
- expression = parser.parse('.def[name=~/foo/]')
351
- expect(expression.query_nodes(node)).to eq [node.body.first, node.body.last]
352
- expression = parser.parse('.def[name!~/bar/]')
353
- expect(expression.query_nodes(node)).to eq [node.body.first]
354
- end
355
-
356
- it 'matches attribute value' do
357
- expression = parser.parse('.pair[key={{value}}]')
358
- expect(expression.query_nodes(node)).to eq node.body.last.body.first.children
359
- end
360
-
361
- it 'matches []' do
362
- expression = parser.parse('.send[message=[]]')
363
- expect(expression.query_nodes(node)).to eq [node.body.last.body.second]
364
- end
365
-
366
- it 'matches []=' do
367
- expression = parser.parse('.send[message=:[]=]')
368
- expect(expression.query_nodes(node)).to eq [node.body.last.body.third]
369
- end
370
-
371
- it 'matches nil and nil?' do
372
- expression = parser.parse('.send[receiver=nil][message=nil?]')
373
- expect(expression.query_nodes(node)).to eq [node.body.last.body.fourth]
374
- end
375
-
376
- it 'matches empty string' do
377
- expression = parser.parse('.send[message=call][arguments.first=""]')
378
- expect(expression.query_nodes(node)).to eq [node.body.last.body.last]
379
- end
380
- end
381
- end
382
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Synvert::Core
6
- describe Rewriter::AppendAction do
7
- describe 'class node' do
8
- subject do
9
- source = "class User\n has_many :posts\nend"
10
- class_node = Parser::CurrentRuby.parse(source)
11
- instance = double(current_node: class_node)
12
- Rewriter::AppendAction.new(instance, "def as_json\n super\nend").process
13
- end
14
-
15
- it 'gets begin_pos' do
16
- expect(subject.begin_pos).to eq "class User\n has_many :posts".length
17
- end
18
-
19
- it 'gets end_pos' do
20
- expect(subject.end_pos).to eq "class User\n has_many :posts".length
21
- end
22
-
23
- it 'gets rewritten_code' do
24
- expect(subject.rewritten_code).to eq "\n\n def as_json\n super\n end"
25
- end
26
- end
27
-
28
- describe 'begin node' do
29
- subject do
30
- source = "gem 'rails'\ngem 'mysql2'"
31
- begin_node = Parser::CurrentRuby.parse(source)
32
- instance = double(current_node: begin_node)
33
- Rewriter::AppendAction.new(instance, "gem 'twitter'").process
34
- end
35
-
36
- it 'gets begin_pos' do
37
- expect(subject.begin_pos).to eq "gem 'rails'\ngem 'mysql2'".length
38
- end
39
-
40
- it 'gets end_pos' do
41
- expect(subject.end_pos).to eq "gem 'rails'\ngem 'mysql2'".length
42
- end
43
-
44
- it 'gets rewritten_code' do
45
- expect(subject.rewritten_code).to eq "\ngem 'twitter'"
46
- end
47
- end
48
-
49
- describe 'def node' do
50
- subject do
51
- source = "def teardown\n do_something\nend"
52
- class_node = Parser::CurrentRuby.parse(source)
53
- instance = double(current_node: class_node)
54
- Rewriter::AppendAction.new(instance, 'super').process
55
- end
56
-
57
- it 'gets begin_pos' do
58
- expect(subject.begin_pos).to eq "def teardown\n do_something".length
59
- end
60
-
61
- it 'gets end_pos' do
62
- expect(subject.end_pos).to eq "def teardown\n do_something".length
63
- end
64
-
65
- it 'gets rewritten_code' do
66
- expect(subject.rewritten_code).to eq "\n super"
67
- end
68
- end
69
- end
70
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Synvert::Core
6
- describe Rewriter::DeleteAction do
7
- subject {
8
- source = 'arr.map {}.flatten'
9
- node = Parser::CurrentRuby.parse(source)
10
- instance = double(current_node: node, file_source: source)
11
- Rewriter::DeleteAction.new(instance, :dot, :message).process
12
- }
13
-
14
- it 'gets begin_pos' do
15
- expect(subject.begin_pos).to eq 'arr.map {}'.length
16
- end
17
-
18
- it 'gets end_pos' do
19
- expect(subject.end_pos).to eq 'arr.map {}.flatten'.length
20
- end
21
-
22
- it 'gets rewritten_code' do
23
- expect(subject.rewritten_code).to eq ''
24
- end
25
- end
26
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Synvert::Core
6
- describe Rewriter::InsertAction do
7
- context 'at end' do
8
- subject {
9
- source = " User.where(username: 'Richard')"
10
- node = Parser::CurrentRuby.parse(source)
11
- instance = double(current_node: node)
12
- Rewriter::InsertAction.new(instance, '.first', at: 'end').process
13
- }
14
-
15
- it 'gets begin_pos' do
16
- expect(subject.begin_pos).to eq " User.where(username: 'Richard')".length
17
- end
18
-
19
- it 'gets end_pos' do
20
- expect(subject.end_pos).to eq " User.where(username: 'Richard')".length
21
- end
22
-
23
- it 'gets rewritten_code' do
24
- expect(subject.rewritten_code).to eq '.first'
25
- end
26
- end
27
-
28
- context 'at beginning' do
29
- subject {
30
- source = " open('http://test.com')"
31
- node = Parser::CurrentRuby.parse(source)
32
- instance = double(current_node: node)
33
- Rewriter::InsertAction.new(instance, 'URI.', at: 'beginning').process
34
- }
35
-
36
- it 'gets begin_pos' do
37
- expect(subject.begin_pos).to eq 2
38
- end
39
-
40
- it 'gets end_pos' do
41
- expect(subject.end_pos).to eq 2
42
- end
43
-
44
- it 'gets rewritten_code' do
45
- expect(subject.rewritten_code).to eq 'URI.'
46
- end
47
- end
48
-
49
- context 'to receiver' do
50
- subject {
51
- source = "User.where(username: 'Richard')"
52
- node = Parser::CurrentRuby.parse(source)
53
- instance = double(current_node: node)
54
- Rewriter::InsertAction.new(instance, '.active', to: 'receiver', at: 'end').process
55
- }
56
-
57
- it 'gets begin_pos' do
58
- expect(subject.begin_pos).to eq "User".length
59
- end
60
-
61
- it 'gets end_pos' do
62
- expect(subject.end_pos).to eq "User".length
63
- end
64
-
65
- it 'gets rewritten_code' do
66
- expect(subject.rewritten_code).to eq '.active'
67
- end
68
- end
69
- end
70
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Synvert::Core
6
- describe Rewriter::InsertAfterAction do
7
- subject {
8
- source = ' include Foo'
9
- node = Parser::CurrentRuby.parse(source)
10
- instance = double(current_node: node)
11
- Rewriter::InsertAfterAction.new(instance, 'include Bar').process
12
- }
13
-
14
- it 'gets begin_pos' do
15
- expect(subject.begin_pos).to eq ' include Foo'.length
16
- end
17
-
18
- it 'gets end_pos' do
19
- expect(subject.end_pos).to eq ' include Foo'.length
20
- end
21
-
22
- it 'gets rewritten_code' do
23
- expect(subject.rewritten_code).to eq "\n include Bar"
24
- end
25
- end
26
- end