File: api_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 (59 lines) | stat: -rw-r--r-- 1,836 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
require "helper"

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

    let(:api) do
      API.new(
        [
          nil,
          {
            "functions" => [
              {"name" => "nvim_func"},
              {"name" => "nvim_buf_func"},
              {"name" => "nvim_win_func"},
              {"name" => "nvim_tabpage_func"}
            ]
          }
        ]
      )
    end

    describe "#functions_for_object_method" do
      it "returns relevant functions" do
        function = api.function_for_object_method(client, :func)
        expect(function.name).to eq("nvim_func")

        function = api.function_for_object_method(client.get_current_buf, :func)
        expect(function.name).to eq("nvim_buf_func")

        function = api.function_for_object_method(client.get_current_win, :func)
        expect(function.name).to eq("nvim_win_func")

        function = api.function_for_object_method(client.get_current_tabpage, :func)
        expect(function.name).to eq("nvim_tabpage_func")
      end
    end

    describe "#functions_for_object" do
      it "returns relevant functions" do
        functions = api.functions_for_object(client)
        expect(functions.size).to be(1)
        expect(functions.first.name).to eq("nvim_func")

        functions = api.functions_for_object(client.get_current_buf)
        expect(functions.size).to be(1)
        expect(functions.first.name).to eq("nvim_buf_func")

        functions = api.functions_for_object(client.get_current_win)
        expect(functions.size).to be(1)
        expect(functions.first.name).to eq("nvim_win_func")

        functions = api.functions_for_object(client.get_current_tabpage)
        expect(functions.size).to be(1)
        expect(functions.first.name).to eq("nvim_tabpage_func")
      end
    end
  end
end