debian-mirror-gitlab/spec/tooling/danger/specs_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
require 'gitlab/dangerfiles/spec_helper'
require_relative '../../../tooling/danger/specs'
2023-03-04 22:38:38 +05:30
RSpec.describe Tooling::Danger::Specs, feature_category: :tooling do
2021-11-18 22:05:49 +05:30
include_context "with dangerfile"
let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
2022-11-25 23:54:43 +05:30
let(:filename) { 'spec/foo_spec.rb' }
2021-11-18 22:05:49 +05:30
subject(:specs) { fake_danger.new(helper: fake_helper) }
describe '#changed_specs_files' do
2023-06-20 00:43:36 +05:30
let(:base_expected_files) do
%w[
spec/foo_spec.rb ee/spec/foo_spec.rb spec/bar_spec.rb
ee/spec/bar_spec.rb spec/zab_spec.rb ee/spec/zab_spec.rb
]
end
2021-11-18 22:05:49 +05:30
before do
all_changed_files = %w[
app/workers/a.rb
app/workers/b.rb
app/workers/e.rb
spec/foo_spec.rb
ee/spec/foo_spec.rb
spec/bar_spec.rb
ee/spec/bar_spec.rb
spec/zab_spec.rb
ee/spec/zab_spec.rb
]
allow(specs.helper).to receive(:all_changed_files).and_return(all_changed_files)
end
it 'returns added, modified, and renamed_after files by default' do
expect(specs.changed_specs_files).to match_array(base_expected_files)
end
context 'with include_ee: :exclude' do
it 'returns spec files without EE-specific files' do
2023-06-20 00:43:36 +05:30
expect(specs.changed_specs_files(ee: :exclude))
.not_to include(%w[ee/spec/foo_spec.rb ee/spec/bar_spec.rb ee/spec/zab_spec.rb])
2021-11-18 22:05:49 +05:30
end
end
context 'with include_ee: :only' do
it 'returns EE-specific spec files only' do
2023-06-20 00:43:36 +05:30
expect(specs.changed_specs_files(ee: :only))
.to match_array(%w[ee/spec/foo_spec.rb ee/spec/bar_spec.rb ee/spec/zab_spec.rb])
2023-03-04 22:38:38 +05:30
end
end
end
2021-11-18 22:05:49 +05:30
end