diff options
author | Hiroshi SHIBATA <[email protected]> | 2022-12-09 15:12:51 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2022-12-09 16:36:22 +0900 |
commit | 0677bbe3ff139a4f369c128bdab3526450c5ee6f (patch) | |
tree | d114f89cd3150e50cfeaa3d20542287dcacf85ae /spec/syntax_suggest/unit/api_spec.rb | |
parent | 9557c8edf2dcf18fdece066c596a71696b2f2b30 (diff) |
Merge syntax_suggest master
Pick from https://github.com/ruby/syntax_suggest/commit/daee74dcb06296fa69fe8595fdff5d93d432b30d
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6890
Diffstat (limited to 'spec/syntax_suggest/unit/api_spec.rb')
-rw-r--r-- | spec/syntax_suggest/unit/api_spec.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/spec/syntax_suggest/unit/api_spec.rb b/spec/syntax_suggest/unit/api_spec.rb index a89d9f6a33..079a91e46d 100644 --- a/spec/syntax_suggest/unit/api_spec.rb +++ b/spec/syntax_suggest/unit/api_spec.rb @@ -65,11 +65,20 @@ module SyntaxSuggest it "respects highlight API" do skip if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2") - error = SyntaxError.new("#{fixtures_dir.join("this_project_extra_def.rb.txt")}:1 ") + core_ext_file = lib_dir.join("syntax_suggest").join("core_ext.rb") + require_relative core_ext_file - skip if error.respond_to?(:path) + error_klass = Class.new do + def path + fixtures_dir.join("this_project_extra_def.rb.txt") + end - require "syntax_suggest/core_ext" + def detailed_message(**kwargs) + "error" + end + end + error_klass.prepend(SyntaxSuggest.module_for_detailed_message) + error = error_klass.new expect(error.detailed_message(highlight: true)).to include(SyntaxSuggest::DisplayCodeWithLineNumbers::TERMINAL_HIGHLIGHT) expect(error.detailed_message(highlight: false)).to_not include(SyntaxSuggest::DisplayCodeWithLineNumbers::TERMINAL_HIGHLIGHT) @@ -78,11 +87,20 @@ module SyntaxSuggest it "can be disabled via falsey kwarg" do skip if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.2") - error = SyntaxError.new("#{fixtures_dir.join("this_project_extra_def.rb.txt")}:1 ") + core_ext_file = lib_dir.join("syntax_suggest").join("core_ext.rb") + require_relative core_ext_file - skip if error.respond_to?(:path) + error_klass = Class.new do + def path + fixtures_dir.join("this_project_extra_def.rb.txt") + end - require "syntax_suggest/core_ext" + def detailed_message(**kwargs) + "error" + end + end + error_klass.prepend(SyntaxSuggest.module_for_detailed_message) + error = error_klass.new expect(error.detailed_message(syntax_suggest: true)).to_not eq(error.detailed_message(syntax_suggest: false)) end |