blob: 09f8d90d335e4cf89c2d54b117ea17c84d1fc78c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# frozen_string_literal: true
require_relative "../../spec_helper"
module SyntaxSuggest
RSpec.describe Capture::BeforeAfterKeywordEnds do
it "before after keyword ends" do
source = <<~EOM
def nope
print 'not me'
end
def lol
print 'lol'
end
def hello # 8
def yolo
print 'haha'
end
def nada
print 'nope'
end
EOM
code_lines = CleanDocument.new(source: source).call.lines
block = CodeBlock.new(lines: code_lines[8])
expect(block.to_s).to include("def hello")
lines = Capture::BeforeAfterKeywordEnds.new(
block: block,
code_lines: code_lines
).call
lines.sort!
expect(lines.join).to include(<<~EOM)
def lol
end
def yolo
end
EOM
end
end
end
|