File: editorconfig_spec.rb

package info (click to toggle)
vim-editorconfig 0.3.3%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 152 kB
  • sloc: ruby: 95; makefile: 2; sh: 1
file content (121 lines) | stat: -rw-r--r-- 2,550 bytes parent folder | download | duplicates (3)
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
require 'vimrunner'

$vim = Vimrunner.start
$vim.add_plugin(File.expand_path('../../..', __FILE__), 'plugin/editorconfig.vim')

# The base path of the testing files
BASE_PATH = File.expand_path('../plugin_tests/test_files/', __FILE__)

# file_name is the file name that should be open by Vim
# expected_values is a Hash that contains all the Vim options we need to test
def test_editorconfig(file_name, expected_values)
  $vim.edit(File.join(BASE_PATH, file_name))

  expected_values.each do |key, val|
    $vim.echo("&l:#{key}").should == val
  end

  $vim.command 'bd!'
end

describe 'plugin/editorconfig.vim' do
  after(:all) do
    $vim.kill
  end

  describe '#all' do
    it '3_space.py' do
      test_editorconfig '3_space.txt',
        expandtab: '1',
        shiftwidth: '3',
        tabstop: '3'
    end
  end

  it '4_space.py' do
    test_editorconfig '4_space.py',
      expandtab: '1',
      shiftwidth: '4',
      tabstop: '8'
  end

  it 'space.txt' do
    test_editorconfig 'space.txt',
      expandtab: '1',
      shiftwidth: $vim.echo('&l:tabstop')
  end

  it 'tab.txt' do
    test_editorconfig 'tab.txt',
      expandtab: '0'
  end

  it '4_tab.txt' do
    test_editorconfig '4_tab.txt',
      expandtab: '0',
      shiftwidth: '4',
      tabstop: '4'
  end

  it '4_tab_width_of_8' do
    test_editorconfig '4_tab_width_of_8.txt',
      expandtab: '0',
      shiftwidth: '4',
      tabstop: '8'
  end

  it 'lf.txt' do
    test_editorconfig 'lf.txt',
      fileformat: 'unix'
  end

  it 'crlf.txt' do
    test_editorconfig 'crlf.txt',
      fileformat: 'dos'
  end

  it 'cr.txt' do
    test_editorconfig 'cr.txt',
      fileformat: 'mac'
  end

  it 'utf-8.txt' do
    test_editorconfig 'utf-8.txt',
      fileencoding: 'utf-8',
      bomb: '0'
  end

  it 'utf-8-bom.txt' do
    test_editorconfig 'utf-8-bom.txt',
      fileencoding: 'utf-8',
      bomb: '1'
  end

  it 'utf-16be.txt' do
    test_editorconfig 'utf-16be.txt',
      fileencoding: 'utf-16'
  end

  it 'utf-16le.txt' do
    test_editorconfig 'utf-16le.txt',
      fileencoding: 'utf-16le'
  end

  it 'latin1.txt' do
    test_editorconfig 'latin1.txt',
      fileencoding: 'latin1'
  end

  # insert_final_newline by PreserveNoEOL tests are omitted, since they are not supported
  if $vim.echo("exists('+fixendofline')") == '1'
    it 'with_newline.txt' do
      test_editorconfig 'with_newline.txt',
        fixendofline: '1'
    end

    it 'without_newline.txt' do
      test_editorconfig 'without_newline.txt',
        fixendofline: '0'
    end
  end
end