File: current_spec.rb

package info (click to toggle)
ruby-neovim 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: ruby: 4,178; sh: 23; makefile: 4
file content (138 lines) | stat: -rw-r--r-- 3,546 bytes parent folder | download
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
require "helper"

module Neovim
  RSpec.describe Current do
    let(:client) { Support.persistent_client }
    let(:current) { client.current }

    describe "#line" do
      it "returns an empty string if the current line is empty" do
        expect(current.line).to eq("")
      end

      it "returns the contents of the line" do
        current.line = "New content"
        expect(current.line).to eq("New content")
      end
    end

    describe "#line=" do
      it "sets the content of the current line" do
        current.line = "New content"
        expect(current.line).to eq("New content")
      end
    end

    describe "#buffer" do
      it "returns the current buffer" do
        expect(current.buffer).to be_a(Buffer)
      end
    end

    describe "#buffer=" do
      it "sets the current buffer from an integer" do
        initial_index = current.buffer.index
        client.command("vnew")

        expect do
          current.buffer = initial_index
        end.to change { current.buffer.index }.to(initial_index)
      end

      it "sets the current buffer from a Buffer" do
        b0 = current.buffer
        client.command("vnew")
        b1 = current.buffer

        expect do
          current.buffer = b0
        end.to change { current.buffer }.from(b1).to(b0)
      end

      it "returns an integer" do
        index = current.buffer.index
        expect(current.buffer = index).to eq(index)
      end

      it "returns a Buffer" do
        buffer = current.buffer
        expect(current.buffer = buffer).to eq(buffer)
      end
    end

    describe "#window" do
      it "returns the current window" do
        expect(current.window).to be_a(Window)
      end
    end

    describe "#window=" do
      it "sets the current window from an integer" do
        start_index = current.window.index
        client.command("vsp")

        expect do
          current.window = start_index
        end.to change { current.window.index }.to(start_index)
      end

      it "sets the current window from a Window" do
        w0 = current.window
        client.command("vsp")
        w1 = current.window

        expect do
          current.window = w0
        end.to change { current.window }.from(w1).to(w0)
      end

      it "returns an integer" do
        index = current.window.index
        expect(current.window = index).to eq(index)
      end

      it "returns a Window" do
        w0 = current.window
        expect(current.window = w0).to eq(w0)
      end
    end

    describe "#tabpage" do
      it "returns the current tabpage" do
        expect(current.tabpage).to be_a(Tabpage)
      end
    end

    describe "#tabpage=" do
      it "sets the current tabpage from an integer" do
        initial_index = current.tabpage.index
        client.command("tabnew")
        expect(current.tabpage.index).not_to eq(initial_index)

        expect do
          current.tabpage = initial_index
        end.to change { current.tabpage.index }.to(initial_index)
      end

      it "sets the current tabpage from a Tabpage" do
        tp0 = current.tabpage
        client.command("tabnew")
        tp1 = current.tabpage

        expect do
          current.tabpage = tp0
        end.to change { current.tabpage }.from(tp1).to(tp0)
      end

      it "returns an integer" do
        index = current.tabpage.index
        expect(current.tabpage = index).to eq(index)
      end

      it "returns a Tabpage" do
        tp0 = current.tabpage
        expect(current.tabpage = tp0).to eq(tp0)
      end
    end
  end
end