|
8 | 8 | let(:config) { double('config') }
|
9 | 9 | let(:context) { double('context') }
|
10 | 10 | let(:hook) { described_class.new(config, context) }
|
| 11 | + |
11 | 12 | describe '#run?' do
|
12 |
| - let(:hook_config) do |
13 |
| - { 'skip' => skip } |
14 |
| - end |
| 13 | + let(:hook_config) { {} } |
15 | 14 |
|
16 | 15 | before do
|
17 | 16 | allow(context).to receive(:remote_name).and_return(remote_name)
|
18 | 17 | allow(context).to receive(:remote_branch_deletion?).and_return(remote_branch_deletion?)
|
19 | 18 | allow(config).to receive(:for_hook).and_return(hook_config)
|
20 | 19 | end
|
21 | 20 |
|
22 |
| - subject { hook.skip? } |
23 |
| - |
24 |
| - context 'skip is true' do |
25 |
| - let(:skip) { true } |
26 |
| - |
27 |
| - it { subject.should == true } |
28 |
| - end |
29 |
| - |
30 |
| - context 'skip is false' do |
31 |
| - let(:skip) { false } |
32 |
| - |
33 |
| - it { subject.should == false } |
34 |
| - end |
| 21 | + subject { hook.run? } |
35 | 22 |
|
36 | 23 | context 'with exclude_remotes specified' do
|
37 | 24 | let(:hook_config) do
|
38 |
| - { 'skip' => skip, 'exclude_remotes' => exclude_remotes } |
| 25 | + { 'exclude_remotes' => exclude_remotes } |
39 | 26 | end
|
40 |
| - let(:exclude_remotes) { nil } |
41 | 27 |
|
42 |
| - context 'skip is true and exclude_remotes is nil' do |
43 |
| - let(:skip) { true } |
| 28 | + context 'exclude_remotes is nil' do |
44 | 29 | let(:exclude_remotes) { nil }
|
45 | 30 |
|
46 | 31 | it { subject.should == true }
|
47 | 32 | end
|
48 | 33 |
|
49 |
| - context 'skip is false and exclude_remotes is nil' do |
50 |
| - let(:skip) { false } |
51 |
| - let(:exclude_remotes) { nil } |
52 |
| - end |
| 34 | + context 'exclude_remotes includes the remote' do |
| 35 | + let(:exclude_remotes) { [remote_name] } |
53 | 36 |
|
54 |
| - context 'skip is true and matching exclude_remotes is nil' do |
55 |
| - let(:skip) { true } |
56 |
| - let(:exclude_remotes) { ['origin'] } |
57 |
| - |
58 |
| - it { subject.should == true } |
59 |
| - end |
60 |
| - |
61 |
| - context 'skip is false and matching exclude_remotes is nil' do |
62 |
| - let(:skip) { false } |
63 |
| - let(:exclude_remotes) { ['origin'] } |
| 37 | + it { subject.should == false } |
64 | 38 | end
|
65 | 39 |
|
66 |
| - context 'skip is true and non-matching exclude_remotes is nil' do |
67 |
| - let(:skip) { true } |
| 40 | + context 'exclude_remotes does not include the remote' do |
68 | 41 | let(:exclude_remotes) { ['heroku'] }
|
69 | 42 |
|
70 | 43 | it { subject.should == true }
|
71 | 44 | end
|
72 |
| - |
73 |
| - context 'skip is false and non-matching exclude_remotes is nil' do |
74 |
| - let(:skip) { false } |
75 |
| - let(:exclude_remotes) { ['heroku'] } |
76 |
| - |
77 |
| - it { subject.should == false } |
78 |
| - end |
79 | 45 | end
|
80 | 46 |
|
81 |
| - context 'with ignore_branch_deletions specified' do |
| 47 | + context 'with include_branch_deletions specified' do |
82 | 48 | let(:hook_config) do
|
83 |
| - { 'skip' => skip, 'ignore_branch_deletions' => ignore_branch_deletions } |
| 49 | + { 'include_branch_deletions' => include_branch_deletions } |
84 | 50 | end
|
85 | 51 | 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 } |
| 52 | + let(:include_branch_deletions) { false } |
| 53 | + |
| 54 | + context 'when remote branch is not being deleted' do |
94 | 55 | let(:remote_branch_deletion?) { false }
|
95 |
| - let(:ignore_branch_deletions) { nil } |
96 | 56 |
|
97 |
| - it { subject.should == true } |
98 |
| - end |
| 57 | + context 'when include_branch_deletions is not specified' do |
| 58 | + let(:include_branch_deletions) { nil } |
99 | 59 |
|
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 } |
| 60 | + it { subject.should == true } |
| 61 | + end |
108 | 62 |
|
109 |
| - it { subject.should == false } |
110 |
| - end |
| 63 | + context 'when include_branch_deletions is false' do |
| 64 | + let(:include_branch_deletions) { false } |
111 | 65 |
|
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 } |
| 66 | + it { subject.should == true } |
| 67 | + end |
120 | 68 |
|
121 |
| - it { subject.should == false } |
| 69 | + context 'when include_branch_deletions is true' do |
| 70 | + let(:include_branch_deletions) { true } |
| 71 | + |
| 72 | + it { subject.should == true } |
| 73 | + end |
122 | 74 | end
|
123 | 75 |
|
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 } |
| 76 | + context 'when remote branch is being deleted' do |
130 | 77 | let(:remote_branch_deletion?) { true }
|
131 |
| - let(:ignore_branch_deletions) { true } |
132 | 78 |
|
133 |
| - it { subject.should == true } |
134 |
| - end |
| 79 | + context 'when include_branch_deletions is not specified' do |
| 80 | + let(:include_branch_deletions) { nil } |
135 | 81 |
|
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 } |
| 82 | + it { subject.should == false } |
| 83 | + end |
144 | 84 |
|
145 |
| - it { subject.should == false } |
146 |
| - end |
| 85 | + context 'when include_branch_deletions is false' do |
| 86 | + let(:include_branch_deletions) { false } |
147 | 87 |
|
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 } |
| 88 | + it { subject.should == false } |
| 89 | + end |
156 | 90 |
|
157 |
| - it { subject.should == true } |
| 91 | + context 'when include_branch_deletions is true' do |
| 92 | + let(:include_branch_deletions) { true } |
| 93 | + |
| 94 | + it { subject.should == true } |
| 95 | + end |
158 | 96 | end
|
159 | 97 | end
|
160 | 98 | end
|
|
0 commit comments