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
|