diff options
Diffstat (limited to 'spec/syntax_suggest')
-rw-r--r-- | spec/syntax_suggest/integration/syntax_suggest_spec.rb | 25 | ||||
-rw-r--r-- | spec/syntax_suggest/unit/around_block_scan_spec.rb | 4 | ||||
-rw-r--r-- | spec/syntax_suggest/unit/block_expand_spec.rb | 30 | ||||
-rw-r--r-- | spec/syntax_suggest/unit/code_search_spec.rb | 1 |
4 files changed, 57 insertions, 3 deletions
diff --git a/spec/syntax_suggest/integration/syntax_suggest_spec.rb b/spec/syntax_suggest/integration/syntax_suggest_spec.rb index 21c02ca287..e96173717d 100644 --- a/spec/syntax_suggest/integration/syntax_suggest_spec.rb +++ b/spec/syntax_suggest/integration/syntax_suggest_spec.rb @@ -234,5 +234,30 @@ module SyntaxSuggest > 10 end # extra end EOM end + + it "space inside of a method" do + source = <<~'EOM' + class Dog # 1 + def bark # 2 + + end # 4 + + def sit # 6 + print "sit" # 7 + end # 8 + end # 9 + end # extra end + EOM + + io = StringIO.new + SyntaxSuggest.call( + io: io, + source: source + ) + out = io.string + expect(out).to include(<<~EOM) + > 10 end # extra end + EOM + end end end diff --git a/spec/syntax_suggest/unit/around_block_scan_spec.rb b/spec/syntax_suggest/unit/around_block_scan_spec.rb index 6053c3947e..be1c3a4780 100644 --- a/spec/syntax_suggest/unit/around_block_scan_spec.rb +++ b/spec/syntax_suggest/unit/around_block_scan_spec.rb @@ -13,7 +13,7 @@ module SyntaxSuggest code_lines = CodeLine.from_source(source) block = CodeBlock.new(lines: code_lines[1]) expand = AroundBlockScan.new(code_lines: code_lines, block: block) - .scan_neighbors + .scan_neighbors_not_empty expect(expand.code_block.to_s).to eq(source) expand.scan_while { |line| false } @@ -151,7 +151,7 @@ module SyntaxSuggest expand = AroundBlockScan.new(code_lines: code_lines, block: block) expand.skip(:empty?) expand.skip(:hidden?) - expand.scan_neighbors + expand.scan_neighbors_not_empty expect(expand.code_block.to_s).to eq(<<~EOM.indent(4)) diff --git a/spec/syntax_suggest/unit/block_expand_spec.rb b/spec/syntax_suggest/unit/block_expand_spec.rb index ba0b0457a1..4f93210368 100644 --- a/spec/syntax_suggest/unit/block_expand_spec.rb +++ b/spec/syntax_suggest/unit/block_expand_spec.rb @@ -4,6 +4,36 @@ require_relative "../spec_helper" module SyntaxSuggest RSpec.describe BlockExpand do + it "empty line in methods" do + source_string = <<~EOM + class Dog # index 0 + def bark # index 1 + + end # index 3 + + def sit # index 5 + print "sit" # index 6 + end # index 7 + end # index 8 + end # extra end + EOM + + code_lines = code_line_array(source_string) + + sit = code_lines[4..7] + sit.each(&:mark_invisible) + + block = CodeBlock.new(lines: sit) + expansion = BlockExpand.new(code_lines: code_lines) + block = expansion.expand_neighbors(block) + + expect(block.to_s).to eq(<<~EOM.indent(2)) + def bark # index 1 + + end # index 3 + EOM + end + it "captures multiple empty and hidden lines" do source_string = <<~EOM def foo diff --git a/spec/syntax_suggest/unit/code_search_spec.rb b/spec/syntax_suggest/unit/code_search_spec.rb index 9a8115c0c8..f836ba36f3 100644 --- a/spec/syntax_suggest/unit/code_search_spec.rb +++ b/spec/syntax_suggest/unit/code_search_spec.rb @@ -338,7 +338,6 @@ module SyntaxSuggest end EOM search.call - puts "done" expect(search.invalid_blocks.join).to eq(<<~'EOM') Foo.call do |