File: vim_spec.rb

package info (click to toggle)
vim-command-t 5.0.2-5-g7147ba9-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 744 kB
  • sloc: ruby: 3,394; ansic: 1,177; makefile: 27; sh: 26; xml: 11
file content (80 lines) | stat: -rw-r--r-- 2,299 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
# Copyright 2014-present Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.

require 'spec_helper'

describe CommandT::VIM do
  describe '.escape_for_single_quotes' do
    it 'turns doubles all single quotes' do
      input = %{it's ''something''}
      expected = %{it''s ''''something''''}
      expect(CommandT::VIM.escape_for_single_quotes(input)).to eq(expected)
    end
  end

  describe '.wildignore_to_regexp' do
    subject do
      Regexp.new(CommandT::VIM.wildignore_to_regexp(wildignore))
    end

    describe '"foo"' do
      let(:wildignore) { 'foo' }

      it 'matches the right strings' do
        expect(subject).to_not match('a.foo')
        expect(subject).to_not match('a/b.foo')
        expect(subject).to match('foo')
        expect(subject).to match('a/foo')
        expect(subject).to_not match('a/foo/b')
      end
    end

    describe '".foo"' do
      let(:wildignore) { '*.foo' }

      it 'matches the right strings' do
        expect(subject).to match('a.foo')
        expect(subject).to match('a/b.foo')
        expect(subject).to_not match('foo')
        expect(subject).to_not match('a/foo')
        expect(subject).to_not match('a/foo/b')
      end
    end

    describe '"*/foo/*"' do
      let(:wildignore) { '*/foo' }

      it 'matches the right strings' do
        expect(subject).to_not match('a.foo')
        expect(subject).to_not match('a/b.foo')
        expect(subject).to match('foo')
        expect(subject).to match('a/foo')
        expect(subject).to match('a/foo/b')
      end
    end

    describe '"*/foo/*"' do
      let(:wildignore) { '*/foo/*' }

      it 'matches the right strings' do
        expect(subject).to_not match('a.foo')
        expect(subject).to_not match('a/b.foo')
        expect(subject).to_not match('foo')
        expect(subject).to_not match('a/foo')
        expect(subject).to match('a/foo/b')
      end
    end

    describe 'multiple patterns' do
      let(:wildignore) { '*.foo,*/foo/*' }

      it 'matches the right strings' do
        expect(subject).to match('a.foo')
        expect(subject).to match('a/b.foo')
        expect(subject).to_not match('foo')
        expect(subject).to_not match('a/foo')
        expect(subject).to match('a/foo/b')
      end
    end
  end
end