1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
require "helper"
require "neovim/ruby_provider/vim"
RSpec.describe Vim do
around do |spec|
client = Vim.instance_variable_get(:@__client)
buffer_cache = Vim.instance_variable_get(:@__buffer_cache)
curbuf = $curbuf
curwin = $curwin
begin
Vim.__client = nil
Vim.instance_variable_set(:@__buffer_cache, {})
$curbuf = nil
$curwin = nil
spec.run
ensure
Vim.__client = client
Vim.instance_variable_set(:@__buffer_cache, buffer_cache)
$curbuf = curbuf
$curwin = curwin
end
end
describe Vim::Buffer do
it "refers to Neovim::Buffer" do
expect(Vim::Buffer).to be(Neovim::Buffer)
end
end
describe Vim::Window do
it "refers to Neovim::Window" do
expect(Vim::Window).to be(Neovim::Window)
end
end
describe VIM do
it "is an alias for the Vim module" do
expect(VIM).to be(Vim)
end
end
describe "#method_missing" do
it "delegates method calls to @__client" do
client = double(:client)
expect(Vim).to receive(:__refresh_globals).with(client)
expect(client).to receive(:foo).with(1, 2)
Vim.__client = client
Vim.foo(1, 2)
end
it "refreshes global variables" do
client = Neovim.attach_child(Support.child_argv)
client.command("vs foo")
Vim.__client = client
Vim.__refresh_globals(client)
expect do
Vim.command("wincmd n")
end.to change { $curwin.index }.by(1)
expect do
Vim.command("vs bar")
end.to change { $curbuf.index }.by(1)
end
end
end
|