File: remote_object_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 (113 lines) | stat: -rw-r--r-- 2,816 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
require "helper"

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

    context Window do
      let(:window) { client.current.window }

      describe "#respond_to?" do
        it "returns true for Window functions" do
          expect(window).to respond_to(:get_cursor)
        end

        it "returns true for Ruby functions" do
          expect(window).to respond_to(:inspect)
        end

        it "returns false otherwise" do
          expect(window).not_to respond_to(:foobar)
        end
      end

      describe "#method_missing" do
        it "enables nvim_win_* function calls" do
          expect(window.get_cursor).to eq([1, 0])
        end

        it "falls back to super" do
          expect { window.foobar }.to raise_error(NoMethodError)
        end
      end

      describe "#methods" do
        it "returns builtin methods" do
          expect(window.methods).to include(:inspect)
        end

        it "returns api methods" do
          expect(window.methods).to include(:get_height)
        end
      end
    end

    context Tabpage do
      let(:tabpage) { client.current.tabpage }

      describe "#respond_to?" do
        it "returns true for Tabpage functions" do
          expect(tabpage).to respond_to(:is_valid)
        end

        it "returns true for Ruby functions" do
          expect(tabpage).to respond_to(:inspect)
        end

        it "returns false otherwise" do
          expect(tabpage).not_to respond_to(:foobar)
        end
      end

      describe "#method_missing" do
        it "enables nvim_tabpage_* function calls" do
          expect(tabpage.is_valid).to be(true)
        end
      end

      describe "#methods" do
        it "returns builtin methods" do
          expect(tabpage.methods).to include(:inspect)
        end

        it "returns api methods" do
          expect(tabpage.methods).to include(:list_wins)
        end
      end
    end

    context Buffer do
      let(:buffer) { client.current.buffer }

      describe "#respond_to?" do
        it "returns true for Buffer functions" do
          expect(buffer).to respond_to(:line_count)
        end

        it "returns true for Ruby functions" do
          expect(buffer).to respond_to(:inspect)
        end

        it "returns false otherwise" do
          expect(buffer).not_to respond_to(:foobar)
        end
      end

      describe "#method_missing" do
        it "enables nvim_buf_* function calls" do
          expect(buffer.line_count).to be(1)
        end
      end

      describe "#methods" do
        it "returns builtin methods" do
          expect(buffer.methods).to include(:inspect)
        end

        it "returns api methods" do
          expect(buffer.methods).to include(:get_mark)
        end
      end
    end
  end
end