File: ruby_spec.vim

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 (84 lines) | stat: -rw-r--r-- 2,075 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
let s:suite = themis#suite(":ruby")
let s:expect = themis#helper("expect")

function! s:suite.before_each() abort
  1,$delete
  call append(0, ["one", "two"])
endfunction

function! s:suite.has_nvim() abort
  call s:expect(has("nvim")).to_equal(1)
endfunction

function! s:suite.defines_a_ruby_method() abort
  ruby def foo; Vim.command("let g:called = 1"); end
  ruby foo

  call s:expect(g:called).to_equal(1)
endfunction

function! s:suite.persists_curbuf_state() abort
  ruby $curbuf.instance_variable_set(:@foo, 123)
  ruby Vim.command("let g:foo = #{$curbuf.instance_variable_get(:@foo)}")

  call s:expect(g:foo).to_equal(123)
endfunction

function! s:suite.updates_working_directory() abort
  cd /
  ruby Vim.command("let g:ruby_pwd = '#{Dir.pwd.sub(/^C:/, "")}'")
  cd -

  call s:expect(g:ruby_pwd).to_equal("/")
endfunction

function! s:suite.updates_working_directory_implicitly() abort
  split | lcd /
  ruby Vim.command("let g:before_pwd = '#{Dir.pwd}'")
  wincmd p
  ruby Vim.command("let g:after_pwd = '#{Dir.pwd}'")
  wincmd p | lcd -

  call s:expect(g:before_pwd).not.to_equal(g:after_pwd)
endfunction

function! s:suite.supports_nesting() abort
  ruby Vim.command("ruby Vim.command('let g:ruby_nested = 123')")

  call s:expect(g:ruby_nested).to_equal(123)
endfunction

function! s:suite.handles_standard_error() abort
  try
    ruby raise "BOOM"
    throw "Nothing raised"
  catch /BOOM/
  endtry

  call s:suite.defines_a_ruby_method()
endfunction

function! s:suite.handles_syntax_error() abort
  try
    ruby puts[
    throw "Nothing raised"
  catch /SyntaxError/
  endtry

  call s:suite.defines_a_ruby_method()
endfunction

function! s:suite.exposes_Vim() abort
  ruby expect(Vim).to eq(VIM)
  ruby expect(Vim.strwidth("hi")).to eq(2)
endfunction

function! s:suite.exposes_Buffer() abort
  ruby expect($curbuf).to be_a(Neovim::Buffer)
  ruby expect(Vim::Buffer.current).to eq($curbuf)
endfunction

function! s:suite.exposes_Window() abort
  ruby expect($curwin).to be_a(Neovim::Window)
  ruby expect(Vim::Window.current).to eq($curwin)
endfunction