File: git_diff_parser_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (46 lines) | stat: -rw-r--r-- 1,168 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
# frozen_string_literal: true

require 'spec_helper'
require './keeps/helpers/git_diff_parser'

RSpec.describe Keeps::Helpers::GitDiffParser, feature_category: :tooling do
  let(:parser) { described_class.new }

  describe '#all_changed_files' do
    let(:diff) do
      <<~DIFF
      diff --git a/foo.txt b/bar.txt
      similarity index 100%
      rename from foo.txt
      rename to bar.txt
      diff --git a/boo.txt b/boo.txt
      new file mode 100644
      index 000000000000..e69de29bb2d1
      diff --git a/boobar.txt b/boobar.txt
      deleted file mode 100644
      index 60b20b312e05..000000000000
      --- a/boobar.txt
      +++ /dev/null
      @@ -1 +0,0 @@
      -something blah blah
      diff --git a/foobar.txt b/foobar.txt
      index 2ef267e25bd6..0fecdb8e98f3 100644
      --- a/foobar.txt
      +++ b/foobar.txt
      @@ -1 +1 @@
      -some content
      +some content updated
      DIFF
    end

    it 'returns all the files mentioned in the diff' do
      expect(parser.all_changed_files(diff)).to contain_exactly(
        'foo.txt',
        'bar.txt',
        'foobar.txt',
        'boo.txt',
        'boobar.txt'
      )
    end
  end
end