Sha256: c47cc9984915c962726b06bcb5487ee772a4b3bf9c0ccf9afcc3dd2d8bb3a8ec

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

require "helper"

module Neovim
  class Host
    RSpec.describe Loader do
      describe "#load" do
        let(:plugin_path) { Support.file_path("plug.rb") }
        let(:host) { instance_double(Host, :register => nil) }
        let(:loader) { Loader.new(host) }

        before do
          File.write(plugin_path, "Neovim.plugin")
        end

        it "registers plugins defined in the provided files" do
          expect(host).to receive(:register).with(kind_of(Plugin))
          loader.load([plugin_path])
        end

        it "registers multiple plugins defined in the provided files" do
          File.write(plugin_path, "Neovim.plugin; Neovim.plugin")
          expect(host).to receive(:register).with(kind_of(Plugin)).twice
          loader.load([plugin_path])
        end

        it "doesn't register plugins when none are defined" do
          File.write(plugin_path, "class FooClass; end")
          expect(host).not_to receive(:register)
          loader.load([plugin_path])
        end

        it "doesn't leak constants defined in plugins" do
          File.write(plugin_path, "class FooClass; end")
          loader.load([plugin_path])
          expect(Kernel.const_defined?(:FooClass)).to be(false)
        end

        it "doesn't leak the overidden Neovim.plugin method" do
          loader.load([plugin_path])
          expect {
            Neovim.plugin
          }.to raise_error(/outside of a plugin host/)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neovim-0.3.0 spec/neovim/host/loader_spec.rb
neovim-0.2.5 spec/neovim/host/loader_spec.rb
neovim-0.2.4 spec/neovim/host/loader_spec.rb
neovim-0.2.3 spec/neovim/host/loader_spec.rb