|
4 | 4 |
|
5 | 5 | describe Overcommit::Hook::PrePush::Base do
|
6 | 6 | let(:remote_name) { 'origin' }
|
| 7 | + let(:remote_branch_deletion?) { false } |
7 | 8 | let(:config) { double('config') }
|
8 | 9 | let(:context) { double('context') }
|
9 | 10 | let(:hook) { described_class.new(config, context) }
|
|
14 | 15 |
|
15 | 16 | before do
|
16 | 17 | allow(context).to receive(:remote_name).and_return(remote_name)
|
| 18 | + allow(context).to receive(:remote_branch_deletion?).and_return(remote_branch_deletion?) |
17 | 19 | allow(config).to receive(:for_hook).and_return(hook_config)
|
18 | 20 | end
|
19 | 21 |
|
|
47 | 49 | context 'skip is false and exclude_remote_names is nil' do
|
48 | 50 | let(:skip) { false }
|
49 | 51 | let(:exclude_remote_names) { nil }
|
50 |
| - |
51 |
| - it { subject.should == false } |
52 | 52 | end
|
53 | 53 |
|
54 | 54 | context 'skip is true and matching exclude_remote_names is nil' do
|
|
61 | 61 | context 'skip is false and matching exclude_remote_names is nil' do
|
62 | 62 | let(:skip) { false }
|
63 | 63 | let(:exclude_remote_names) { ['origin'] }
|
64 |
| - |
65 |
| - it { subject.should == true } |
66 | 64 | end
|
67 | 65 |
|
68 | 66 | context 'skip is true and non-matching exclude_remote_names is nil' do
|
|
79 | 77 | it { subject.should == false }
|
80 | 78 | end
|
81 | 79 | end
|
| 80 | + |
| 81 | + context 'with ignore_branch_deletions specified' do |
| 82 | + let(:hook_config) do |
| 83 | + { 'skip' => skip, 'ignore_branch_deletions' => ignore_branch_deletions } |
| 84 | + end |
| 85 | + let(:remote_branch_deletion?) { false } |
| 86 | + let(:ignore_branch_deletions) { false } |
| 87 | + |
| 88 | + context(<<~DESC) do |
| 89 | + skip is true and |
| 90 | + remote_branch_deletion? is false and |
| 91 | + ignore_branch_deletions false' do |
| 92 | + DESC |
| 93 | + let(:skip) { true } |
| 94 | + let(:remote_branch_deletion?) { false } |
| 95 | + let(:ignore_branch_deletions) { nil } |
| 96 | + |
| 97 | + it { subject.should == true } |
| 98 | + end |
| 99 | + |
| 100 | + context(<<~DESC) do |
| 101 | + skip is false and |
| 102 | + remote_branch_deletion? is false and |
| 103 | + ignore_branch_deletions false' do |
| 104 | + DESC |
| 105 | + let(:skip) { false } |
| 106 | + let(:remote_branch_deletion?) { false } |
| 107 | + let(:ignore_branch_deletions) { false } |
| 108 | + |
| 109 | + it { subject.should == false } |
| 110 | + end |
| 111 | + |
| 112 | + context(<<~DESC) do |
| 113 | + skip is false and |
| 114 | + remote_branch_deletion? is true and |
| 115 | + ignore_branch_deletions false' do |
| 116 | + DESC |
| 117 | + let(:skip) { false } |
| 118 | + let(:remote_branch_deletion?) { true } |
| 119 | + let(:ignore_branch_deletions) { false } |
| 120 | + |
| 121 | + it { subject.should == false } |
| 122 | + end |
| 123 | + |
| 124 | + context(<<~DESC) do |
| 125 | + skip is false and |
| 126 | + remote_branch_deletion? is true and |
| 127 | + ignore_branch_deletions true' do |
| 128 | + DESC |
| 129 | + let(:skip) { false } |
| 130 | + let(:remote_branch_deletion?) { true } |
| 131 | + let(:ignore_branch_deletions) { true } |
| 132 | + |
| 133 | + it { subject.should == true } |
| 134 | + end |
| 135 | + |
| 136 | + context(<<~DESC) do |
| 137 | + skip is false and |
| 138 | + remote_branch_deletion? is false and |
| 139 | + ignore_branch_deletions true' do |
| 140 | + DESC |
| 141 | + let(:skip) { false } |
| 142 | + let(:remote_branch_deletion?) { false } |
| 143 | + let(:ignore_branch_deletions) { true } |
| 144 | + |
| 145 | + it { subject.should == false } |
| 146 | + end |
| 147 | + |
| 148 | + context(<<-DESC) do |
| 149 | + skip is true and |
| 150 | + remote_branch_deletion? is true and |
| 151 | + ignore_branch_deletions true' do |
| 152 | + DESC |
| 153 | + let(:skip) { true } |
| 154 | + let(:remote_branch_deletion?) { true } |
| 155 | + let(:ignore_branch_deletions) { true } |
| 156 | + |
| 157 | + it { subject.should == true } |
| 158 | + end |
| 159 | + end |
82 | 160 | end
|
83 | 161 | end
|
0 commit comments