summaryrefslogtreecommitdiff
path: root/spec/syntax_suggest/integration
diff options
context:
space:
mode:
Diffstat (limited to 'spec/syntax_suggest/integration')
-rw-r--r--spec/syntax_suggest/integration/ruby_command_line_spec.rb12
-rw-r--r--spec/syntax_suggest/integration/syntax_suggest_spec.rb45
2 files changed, 37 insertions, 20 deletions
diff --git a/spec/syntax_suggest/integration/ruby_command_line_spec.rb b/spec/syntax_suggest/integration/ruby_command_line_spec.rb
index b41a4c86e3..02354ceff0 100644
--- a/spec/syntax_suggest/integration/ruby_command_line_spec.rb
+++ b/spec/syntax_suggest/integration/ruby_command_line_spec.rb
@@ -9,7 +9,7 @@ module SyntaxSuggest
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
- script.write <<~'EOM'
+ script.write <<~EOM
puts Kernel.private_methods
EOM
@@ -94,8 +94,6 @@ module SyntaxSuggest
end
it "gem can be tested when executing on Ruby with default gem included" do
- skip if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2")
-
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest -e "puts SyntaxError.instance_method(:detailed_message).source_location" 2>&1`
expect($?.success?).to be_truthy
@@ -103,8 +101,6 @@ module SyntaxSuggest
end
it "annotates a syntax error in Ruby 3.2+ when require is not used" do
- skip if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2")
-
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
@@ -159,7 +155,7 @@ module SyntaxSuggest
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
- script.write <<~'EOM'
+ script.write <<~EOM
$stderr = STDOUT
eval("def lol")
EOM
@@ -167,7 +163,7 @@ module SyntaxSuggest
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
expect($?.success?).to be_falsey
- expect(out).to include("(eval):1")
+ expect(out).to match(/\(eval.*\):1/)
expect(out).to_not include("SyntaxSuggest")
expect(out).to_not include("Could not find filename")
@@ -178,7 +174,7 @@ module SyntaxSuggest
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
- script.write <<~'EOM'
+ script.write <<~EOM
break
EOM
diff --git a/spec/syntax_suggest/integration/syntax_suggest_spec.rb b/spec/syntax_suggest/integration/syntax_suggest_spec.rb
index 64dafabcdd..de9bc5d38e 100644
--- a/spec/syntax_suggest/integration/syntax_suggest_spec.rb
+++ b/spec/syntax_suggest/integration/syntax_suggest_spec.rb
@@ -13,7 +13,7 @@ module SyntaxSuggest
io = StringIO.new
- benchmark = Benchmark.measure do
+ benchmark_measure do
debug_perf do
SyntaxSuggest.call(
io: io,
@@ -24,9 +24,8 @@ module SyntaxSuggest
end
debug_display(io.string)
- debug_display(benchmark)
- expect(io.string).to include(<<~'EOM')
+ expect(io.string).to include(<<~EOM)
6 class SyntaxTree < Ripper
170 def self.parse(source)
174 end
@@ -42,7 +41,7 @@ module SyntaxSuggest
io = StringIO.new
debug_perf do
- benchmark = Benchmark.measure do
+ benchmark_measure do
SyntaxSuggest.call(
io: io,
source: file.read,
@@ -50,11 +49,10 @@ module SyntaxSuggest
)
end
debug_display(io.string)
- debug_display(benchmark)
end
expect(io.string).to_not include("def ruby_install_binstub_path")
- expect(io.string).to include(<<~'EOM')
+ expect(io.string).to include(<<~EOM)
> 1067 def add_yarn_binary
> 1068 return [] if yarn_preinstalled?
> 1069 |
@@ -72,7 +70,7 @@ module SyntaxSuggest
)
debug_display(io.string)
- expect(io.string).to include(<<~'EOM')
+ expect(io.string).to include(<<~EOM)
1 Rails.application.routes.draw do
> 113 namespace :admin do
> 116 match "/foobar(*path)", via: :all, to: redirect { |_params, req|
@@ -91,7 +89,7 @@ module SyntaxSuggest
)
debug_display(io.string)
- expect(io.string).to include(<<~'EOM')
+ expect(io.string).to include(<<~EOM)
1 describe "webmock tests" do
22 it "body" do
27 query = Cutlass::FunctionQuery.new(
@@ -113,7 +111,7 @@ module SyntaxSuggest
)
debug_display(io.string)
- expect(io.string).to include(<<~'EOM')
+ expect(io.string).to include(<<~EOM)
5 module DerailedBenchmarks
6 class RequireTree
> 13 def initialize(name)
@@ -166,7 +164,7 @@ module SyntaxSuggest
end
it "ambiguous end" do
- source = <<~'EOM'
+ source = <<~EOM
def call # 0
print "lol" # 1
end # one # 2
@@ -186,7 +184,7 @@ module SyntaxSuggest
end
it "simple regression" do
- source = <<~'EOM'
+ source = <<~EOM
class Dog
def bark
puts "woof"
@@ -205,8 +203,31 @@ module SyntaxSuggest
EOM
end
+ it "multi-line chain with missing paren" do
+ source = <<~EOM
+ class Dog
+ def bark
+ User
+ .where(name: "schneems"
+ .first
+ end
+ end
+ EOM
+ io = StringIO.new
+ SyntaxSuggest.call(
+ io: io,
+ source: source
+ )
+ out = io.string
+ expect(out).to include(<<~EOM)
+ > 3 User
+ > 4 .where(name: "schneems"
+ > 5 .first
+ EOM
+ end
+
it "empty else" do
- source = <<~'EOM'
+ source = <<~EOM
class Foo
def foo
if cond?