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
|
require "helper"
require "neovim/host"
module Neovim
class Host
RSpec.describe Loader do
describe "#load" do
let(:plugin_path) { Support.file_path("plug.rb") }
let(:host) { instance_double(Host, plugins: []) }
let(:loader) { Loader.new(host) }
before do
File.write(plugin_path, "Neovim.plugin")
end
it "registers plugins defined in the provided files" do
expect do
loader.load([plugin_path])
end.to change { host.plugins.size }.by(1)
end
it "registers multiple plugins defined in the provided files" do
File.write(plugin_path, "Neovim.plugin; Neovim.plugin")
expect do
loader.load([plugin_path])
end.to change { host.plugins.size }.by(2)
end
it "doesn't register plugins when none are defined" do
File.write(plugin_path, "class FooClass; end")
expect do
loader.load([plugin_path])
end.not_to change { host.plugins.size }
end
it "doesn't leak constants defined in plugins" do
File.write(plugin_path, "class FooClass; end")
expect do
loader.load([plugin_path])
end.not_to change { Kernel.const_defined?(:FooClass) }.from(false)
end
it "doesn't leak the overidden Neovim.plugin method" do
loader.load([plugin_path])
expect do
Neovim.plugin
end.to raise_error(/outside of a plugin host/)
end
end
end
end
end
|