-
Notifications
You must be signed in to change notification settings - Fork 356
/
api_version_spec.rb
29 lines (22 loc) · 966 Bytes
/
api_version_spec.rb
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
require 'spec_helper'
require 'vcap/digester'
RSpec.describe 'Stable API warning system', api_version_check: true do
API_FOLDER_CHECKSUM = '5e3e3c64074e05882c6748b578a9a62f80694c94'.freeze
it 'tells the developer if the API specs change' do
api_folder = File.expand_path('..', __FILE__)
filenames = Dir.glob("#{api_folder}/**/*").reject { |filename| File.directory?(filename) || filename == __FILE__ || filename.include?('v3') }.sort
all_file_checksum = filenames.each_with_object('') do |filename, memo|
memo << Digester.new.digest_path(filename)
end
new_checksum = Digester.new.digest(all_file_checksum)
expect(new_checksum).to eql(API_FOLDER_CHECKSUM),
<<~END
You are about to make a breaking change in API!
Do you really want to do it? Then update the checksum (see below) & CC version.
expected:
#{API_FOLDER_CHECKSUM}
got:
#{new_checksum}
END
end
end