Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions spec/integration/ruby_command_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative "../spec_helper"

module SyntaxSuggest
ruby = ENV.fetch("RUBY", "ruby")
RSpec.describe "Requires with ruby cli" do
it "namespaces all monkeypatched methods" do
Dir.mktmpdir do |dir|
Expand All @@ -16,9 +17,9 @@ module SyntaxSuggest
api_only_methods_file = tmpdir.join("api_only_methods.txt")
kernel_methods_file = tmpdir.join("kernel_methods.txt")

d_pid = Process.spawn("ruby -I#{lib_dir} -rsyntax_suggest #{script} 2>&1 > #{syntax_suggest_methods_file}")
k_pid = Process.spawn("ruby #{script} 2>&1 >> #{kernel_methods_file}")
r_pid = Process.spawn("ruby -I#{lib_dir} -rsyntax_suggest/api #{script} 2>&1 > #{api_only_methods_file}")
d_pid = Process.spawn("#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1 > #{syntax_suggest_methods_file}")
k_pid = Process.spawn("#{ruby} #{script} 2>&1 >> #{kernel_methods_file}")
r_pid = Process.spawn("#{ruby} -I#{lib_dir} -rsyntax_suggest/api #{script} 2>&1 > #{api_only_methods_file}")

Process.wait(k_pid)
Process.wait(d_pid)
Expand Down Expand Up @@ -69,7 +70,7 @@ module SyntaxSuggest
load "#{script.expand_path}"
EOM

out = `ruby -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`

expect($?.success?).to be_falsey
expect(out).to include('> 5 it "flerg"').once
Expand All @@ -80,7 +81,7 @@ module SyntaxSuggest
skip if ruby_core?
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`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest -e "puts SyntaxError.instance_method(:detailed_message).source_location" 2>&1`

expect($?.success?).to be_truthy
expect(out).to include(lib_dir.join("syntax_suggest").join("core_ext.rb").to_s).once
Expand All @@ -106,7 +107,7 @@ module SyntaxSuggest
end
EOM

out = `ruby -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`

expect($?.success?).to be_falsey
expect(out).to include('> 5 it "flerg"').once
Expand All @@ -133,7 +134,7 @@ class Dog
load "#{script.expand_path}"
EOM

out = `ruby -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{require_rb} 2>&1`

expect($?.success?).to be_truthy
expect(out).to include("SyntaxSuggest is NOT loaded").once
Expand All @@ -149,7 +150,7 @@ class Dog
eval("def lol")
EOM

out = `ruby -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`

expect($?.success?).to be_falsey
expect(out).to include("(eval):1")
Expand All @@ -167,11 +168,11 @@ class Dog
break
EOM

out = `ruby -I#{lib_dir} -rsyntax_suggest -e "require_relative '#{script}'" 2>&1`
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest -e "require_relative '#{script}'" 2>&1`

expect($?.success?).to be_falsey
expect(out.downcase).to_not include("syntax ok")
puts out
expect(out).to include("Invalid break")
end
end
end
Expand Down