File: window_ext_spec.rb

package info (click to toggle)
ruby-neovim 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 480 kB
  • sloc: ruby: 3,392; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (2)
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
require "helper"
require "neovim/ruby_provider/window_ext"

module Neovim
  RSpec.describe Window do
    let!(:nvim) do
      Neovim.attach_child(Support.child_argv).tap do |nvim|
        stub_const("::Vim", nvim)
      end
    end

    after { nvim.shutdown }

    describe ".current" do
      it "returns the current window from the global Vim client" do
        expect(Window.current).to eq(nvim.get_current_win)
      end
    end

    describe ".count" do
      it "returns the current window count from the global Vim client" do
        expect do
          nvim.command("new")
        end.to change { Window.count }.by(1)
      end

      it "only includes windows within a tabpage" do
        expect do
          nvim.command("tabnew")
        end.not_to change { Window.count }.from(1)
      end
    end

    describe ".[]" do
      it "returns the window at the given index" do
        expect do
          nvim.command("new")
        end.to change { Window[1] }.from(nil).to(kind_of(Window))
      end

      it "only includes windows within a tabpage" do
        nvim.command("new")

        expect do
          nvim.command("tabnew")
        end.to change { Window[1] }.from(kind_of(Window)).to(nil)
      end
    end
  end
end