debian-mirror-gitlab/spec/lib/gitlab/git/gitmodules_parser_spec.rb

32 lines
1 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Git::GitmodulesParser do
2019-07-07 11:18:12 +05:30
it 'parses a .gitmodules file correctly' do
2018-05-09 12:01:36 +05:30
data = <<~GITMODULES
2017-09-10 17:25:29 +05:30
[submodule "vendor/libgit2"]
path = vendor/libgit2
[submodule "vendor/libgit2"]
url = https://github.com/nodegit/libgit2.git
# a comment
[submodule "moved"]
path = new/path
url = https://example.com/some/project
[submodule "bogus"]
url = https://example.com/another/project
GITMODULES
2018-05-09 12:01:36 +05:30
parser = described_class.new(data.gsub("\n", "\r\n"))
2017-09-10 17:25:29 +05:30
modules = parser.parse
expect(modules).to eq({
'vendor/libgit2' => { 'name' => 'vendor/libgit2',
'url' => 'https://github.com/nodegit/libgit2.git' },
'new/path' => { 'name' => 'moved',
'url' => 'https://example.com/some/project' }
})
end
end