File: deprecation_handling_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 (38 lines) | stat: -rw-r--r-- 1,023 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
# frozen_string_literal: true

require 'spec_helper'

require_relative '../../../tooling/docs/deprecation_handling'

RSpec.describe Docs::DeprecationHandling do
  let(:type) { 'deprecation' }

  subject { described_class.new(type).render }

  before do
    allow(Rake::FileList).to receive(:new).and_return(
      ['14-10-c.yml', '14-2-b.yml', '14-2-a.yml']
    )
    # Create dummy YAML data based on file name
    allow(YAML).to receive(:safe_load_file) do |file_name|
      {
        'title' => file_name[/[a-z]*\.yml/],
        'removal_milestone' => file_name[/\d+-\d+/].tr('-', '.')
      }
    end
  end

  it 'sorts entries and milestones' do
    allow_next_instance_of(ERB) do |template|
      expect(template).to receive(:result_with_hash) do |arguments|
        milestones = arguments[:milestones]
        entries = arguments[:entries]

        expect(milestones).to eq(['14.10', '14.2'])
        expect(entries.map { |e| e['title'] }).to eq(['a.yml', 'b.yml', 'c.yml'])
      end
    end

    subject
  end
end