Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added failing (and passing?) tests #573

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
88 changes: 88 additions & 0 deletions spec/language_server/message/text_document/rename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,92 @@ class Foo
rename.process
expect(rename.result[:changes]['file:///file.rb'].length).to eq(2)
end

it "renames an argument symbol from method signature" do
host = Solargraph::LanguageServer::Host.new
host.start
host.open('file:///file.rb', %(
class Example
def foo(bar)
bar += 1
return bar
end
end
), 1)
rename = Solargraph::LanguageServer::Message::TextDocument::Rename.new(host, {
'id' => 1,
'method' => 'textDocument/rename',
'params' => {
'textDocument' => {
'uri' => 'file:///file.rb'
},
'position' => {
'line' => 2,
'character' => 14
},
'newName' => 'baz'
}
})
rename.process
expect(rename.result[:changes]['file:///file.rb'].length).to eq(3)
end

it "renames an argument symbol from method body" do
host = Solargraph::LanguageServer::Host.new
host.start
host.open('file:///file.rb', %(
class Example
def foo(bar)
bar += 1
return bar
end
end
), 1)
rename = Solargraph::LanguageServer::Message::TextDocument::Rename.new(host, {
'id' => 1,
'method' => 'textDocument/rename',
'params' => {
'textDocument' => {
'uri' => 'file:///file.rb'
},
'position' => {
'line' => 3,
'character' => 6
},
'newName' => 'baz'
}
})
rename.process
expect(rename.result[:changes]['file:///file.rb'].length).to eq(3)
end

it "renames namespace symbol with proper range" do
host = Solargraph::LanguageServer::Host.new
host.start
host.open('file:///file.rb', %(
module Namespace; end
class Namespace::ExampleClass
end
obj = Namespace::ExampleClass.new
), 1)
rename = Solargraph::LanguageServer::Message::TextDocument::Rename.new(host, {
'id' => 1,
'method' => 'textDocument/rename',
'params' => {
'textDocument' => {
'uri' => 'file:///file.rb'
},
'position' => {
'line' => 2,
'character' => 12
},
'newName' => 'Nameplace'
}
})
rename.process
changes = rename.result[:changes]['file:///file.rb']
expect(changes.length).to eq(3)
expect(changes.first[:range][:start][:character]).to eq(13)
expect(changes.first[:range][:end][:character]).to eq(22)
end
end