summaryrefslogtreecommitdiff
path: root/spec/syntax_suggest/unit/code_line_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/syntax_suggest/unit/code_line_spec.rb')
-rw-r--r--spec/syntax_suggest/unit/code_line_spec.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/spec/syntax_suggest/unit/code_line_spec.rb b/spec/syntax_suggest/unit/code_line_spec.rb
index cc4fa48bc9..309d3d1c1e 100644
--- a/spec/syntax_suggest/unit/code_line_spec.rb
+++ b/spec/syntax_suggest/unit/code_line_spec.rb
@@ -5,7 +5,7 @@ require_relative "../spec_helper"
module SyntaxSuggest
RSpec.describe CodeLine do
it "bug in keyword detection" do
- lines = CodeLine.from_source(<<~'EOM')
+ lines = CodeLine.from_source(<<~EOM)
def to_json(*opts)
{
type: :module,
@@ -17,9 +17,7 @@ module SyntaxSuggest
end
it "supports endless method definitions" do
- skip("Unsupported ruby version") unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3")
-
- line = CodeLine.from_source(<<~'EOM').first
+ line = CodeLine.from_source(<<~EOM).first
def square(x) = x * x
EOM
@@ -28,7 +26,7 @@ module SyntaxSuggest
end
it "retains original line value, after being marked invisible" do
- line = CodeLine.from_source(<<~'EOM').first
+ line = CodeLine.from_source(<<~EOM).first
puts "lol"
EOM
expect(line.line).to match('puts "lol"')
@@ -38,7 +36,7 @@ module SyntaxSuggest
end
it "knows which lines can be joined" do
- code_lines = CodeLine.from_source(<<~'EOM')
+ code_lines = CodeLine.from_source(<<~EOM)
user = User.
where(name: 'schneems').
first
@@ -46,10 +44,11 @@ module SyntaxSuggest
EOM
# Indicates line 1 can join 2, 2 can join 3, but 3 won't join it's next line
- expect(code_lines.map(&:ignore_newline_not_beg?)).to eq([true, true, false, false])
+ expect(code_lines.map(&:consecutive?)).to eq([true, true, false, false])
end
+
it "trailing if" do
- code_lines = CodeLine.from_source(<<~'EOM')
+ code_lines = CodeLine.from_source(<<~EOM)
puts "lol" if foo
if foo
end
@@ -59,7 +58,7 @@ module SyntaxSuggest
end
it "trailing unless" do
- code_lines = CodeLine.from_source(<<~'EOM')
+ code_lines = CodeLine.from_source(<<~EOM)
puts "lol" unless foo
unless foo
end
@@ -130,14 +129,15 @@ module SyntaxSuggest
it "knows empty lines" do
code_lines = CodeLine.from_source(<<~EOM)
- # Not empty
+ # Comment only
+ foo # Inline comment
- # Not empty
+ bar
EOM
- expect(code_lines.map(&:empty?)).to eq([false, true, false])
- expect(code_lines.map(&:not_empty?)).to eq([true, false, true])
- expect(code_lines.map { |l| SyntaxSuggest.valid?(l) }).to eq([true, true, true])
+ expect(code_lines.map(&:empty?)).to eq([true, false, true, false])
+ expect(code_lines.map(&:not_empty?)).to eq([false, true, false, true])
+ expect(code_lines.map { |l| SyntaxSuggest.valid?(l) }).to eq([true, true, true, true])
end
it "counts indentations" do