gitx 2.21.3 → 2.21.4.ci.145.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,8 @@ describe Gitx::Cli::IntegrateCommand do
9
9
  pretend: true
10
10
  }
11
11
  end
12
- let(:cli) { Gitx::Cli::IntegrateCommand.new(args, options, config) }
12
+ let(:cli) { described_class.new(args, options, config) }
13
+ let(:executor) { cli.send(:executor) }
13
14
  let(:current_branch) { double('fake branch', name: 'feature-branch', head?: true) }
14
15
  let(:repo) { cli.send(:repo) }
15
16
  let(:remote_branch_names) { ['origin/staging', 'origin/prototype'] }
@@ -29,14 +30,13 @@ describe Gitx::Cli::IntegrateCommand do
29
30
  context 'when integration branch is ommitted and remote branch exists' do
30
31
  let(:remote_branch_names) { ['origin/staging'] }
31
32
  before do
32
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
33
-
34
- expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
35
- expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
36
- expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
37
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').ordered
38
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
39
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
33
+ expect(executor).to receive(:execute).with('git', 'update').ordered
34
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
35
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
36
+ expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
37
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrating feature-branch into staging (Pull request #10)', 'feature-branch').ordered
38
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
39
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
40
40
 
41
41
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
42
42
  cli.integrate
@@ -51,14 +51,13 @@ describe Gitx::Cli::IntegrateCommand do
51
51
  let(:local_branch_names) { ['master'] }
52
52
  let(:remote_branch_names) { ['origin/staging'] }
53
53
  before do
54
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
55
-
56
- expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
57
- expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
58
- expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
59
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating master into staging" master').ordered
60
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
61
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
54
+ expect(executor).to receive(:execute).with('git', 'update').ordered
55
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
56
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
57
+ expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
58
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrating master into staging', 'master').ordered
59
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
60
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
62
61
 
63
62
  cli.integrate
64
63
  end
@@ -78,18 +77,20 @@ describe Gitx::Cli::IntegrateCommand do
78
77
  }
79
78
  }
80
79
  end
80
+ let(:changelog) { '2013-01-01 did some stuff' }
81
81
  before do
82
82
  allow(cli).to receive(:ask_editor).and_return('description')
83
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update).twice
84
83
 
85
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
86
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %B'").and_return('2013-01-01 did some stuff').ordered
87
- expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
88
- expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
89
- expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
90
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').ordered
91
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
92
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
84
+ expect(executor).to receive(:execute).with('git', 'update').ordered
85
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
86
+ expect(executor).to receive(:execute).with('git', 'update').ordered
87
+ expect(executor).to receive(:execute).with('git', 'log', 'master...feature-branch', '--reverse', '--no-merges', "--pretty=format:'* %B'").and_return(changelog).ordered
88
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
89
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
90
+ expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
91
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrating feature-branch into staging (Pull request #10)', 'feature-branch').ordered
92
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
93
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
93
94
 
94
95
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls').to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
95
96
 
@@ -107,18 +108,16 @@ describe Gitx::Cli::IntegrateCommand do
107
108
  context 'when staging branch does not exist remotely' do
108
109
  let(:remote_branch_names) { [] }
109
110
  before do
110
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
111
-
112
111
  expect(repo).to receive(:create_branch).with('staging', 'master')
113
112
 
114
- expect(cli).to receive(:run_cmd).with('git push origin staging:staging').ordered
115
-
116
- expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
117
- expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
118
- expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
119
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').ordered
120
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
121
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
113
+ expect(executor).to receive(:execute).with('git', 'update').ordered
114
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'staging:staging').ordered
115
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
116
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').and_raise(Gitx::Executor::ExecutionError).ordered
117
+ expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
118
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrating feature-branch into staging (Pull request #10)', 'feature-branch').ordered
119
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
120
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
122
121
 
123
122
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
124
123
  cli.integrate
@@ -131,14 +130,13 @@ describe Gitx::Cli::IntegrateCommand do
131
130
  context 'when integration branch == prototype and remote branch exists' do
132
131
  let(:remote_branch_names) { ['origin/prototype'] }
133
132
  before do
134
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
135
-
136
- expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
137
- expect(cli).to receive(:run_cmd).with('git branch -D prototype', allow_failure: true).ordered
138
- expect(cli).to receive(:run_cmd).with('git checkout prototype').ordered
139
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into prototype (Pull request #10)" feature-branch').ordered
140
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
141
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
133
+ expect(executor).to receive(:execute).with('git', 'update').ordered
134
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
135
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
136
+ expect(executor).to receive(:execute).with('git', 'checkout', 'prototype').ordered
137
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrating feature-branch into prototype (Pull request #10)', 'feature-branch').ordered
138
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
139
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
142
140
 
143
141
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
144
142
  cli.integrate 'prototype'
@@ -153,26 +151,14 @@ describe Gitx::Cli::IntegrateCommand do
153
151
  expect { cli.integrate('some-other-branch') }.to raise_error(/Invalid aggregate branch: some-other-branch must be one of supported aggregate branches/)
154
152
  end
155
153
  end
156
- context 'when merge conflicts occur during the Gitx::Cli::UpdateCommand execution' do
157
- let(:remote_branch_names) { ['origin/staging'] }
158
- before do
159
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update).and_raise(Gitx::Cli::BaseCommand::MergeError)
160
-
161
- expect { cli.integrate }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the integrate command')
162
- end
163
- it 'raises a helpful error' do
164
- should meet_expectations
165
- end
166
- end
167
154
  context 'when merge conflicts occur with the integrate command' do
168
155
  let(:remote_branch_names) { ['origin/staging'] }
169
156
  before do
170
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
171
-
172
- expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
173
- expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
174
- expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
175
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').and_raise('git merge feature-branch failed').ordered
157
+ expect(executor).to receive(:execute).with('git', 'update').ordered
158
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
159
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
160
+ expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
161
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrating feature-branch into staging (Pull request #10)', 'feature-branch').and_raise('git merge feature-branch failed').ordered
176
162
 
177
163
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
178
164
  expect { cli.integrate }.to raise_error(/Merge conflict occurred. Please fix merge conflict and rerun command with --resume feature-branch flag/)
@@ -190,11 +176,10 @@ describe Gitx::Cli::IntegrateCommand do
190
176
  end
191
177
  let(:repo) { cli.send(:repo) }
192
178
  before do
193
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
194
-
195
- expect(cli).not_to receive(:run_cmd).with('git branch -D staging')
196
- expect(cli).not_to receive(:run_cmd).with('git push origin HEAD')
197
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch')
179
+ expect(executor).to receive(:execute).with('git', 'update').ordered
180
+ expect(executor).not_to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging')
181
+ expect(executor).not_to receive(:execute).with('git', 'push', 'origin', 'HEAD')
182
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch')
198
183
 
199
184
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
200
185
  cli.integrate
@@ -212,12 +197,12 @@ describe Gitx::Cli::IntegrateCommand do
212
197
  end
213
198
  let(:local_branch_names) { ['feature-branch'] }
214
199
  before do
215
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
200
+ expect(executor).to receive(:execute).with('git', 'update').ordered
216
201
  expect(cli).to receive(:ask).and_return('feature-branch')
217
202
 
218
- expect(cli).not_to receive(:run_cmd).with('git branch -D staging')
219
- expect(cli).not_to receive(:run_cmd).with('git push origin HEAD')
220
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
203
+ expect(executor).not_to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging')
204
+ expect(executor).not_to receive(:execute).with('git', 'push', 'origin', 'HEAD')
205
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
221
206
 
222
207
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
223
208
  cli.integrate
@@ -9,7 +9,8 @@ describe Gitx::Cli::NukeCommand do
9
9
  pretend: true
10
10
  }
11
11
  end
12
- let(:cli) { Gitx::Cli::NukeCommand.new(args, options, config) }
12
+ let(:cli) { described_class.new(args, options, config) }
13
+ let(:executor) { cli.send(:executor) }
13
14
  let(:branch) { double('fake branch', name: 'feature-branch') }
14
15
 
15
16
  before do
@@ -31,13 +32,12 @@ describe Gitx::Cli::NukeCommand do
31
32
 
32
33
  expect(cli).to receive(:current_build_tag).with(good_branch).and_return(buildtag)
33
34
 
34
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
35
- expect(cli).to receive(:run_cmd).with('git branch -D prototype', allow_failure: true).ordered
36
- expect(cli).to receive(:run_cmd).with('git push origin --delete prototype', allow_failure: true).ordered
37
- expect(cli).to receive(:run_cmd).with('git checkout -b prototype build-master-2013-10-01-01').ordered
38
- expect(cli).to receive(:run_cmd).with('git push origin prototype').ordered
39
- expect(cli).to receive(:run_cmd).with('git branch --set-upstream-to origin/prototype').ordered
40
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
35
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
36
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
37
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'prototype').ordered
38
+ expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'build-master-2013-10-01-01').ordered
39
+ expect(executor).to receive(:execute).with('git', 'share').ordered
40
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
41
41
 
42
42
  cli.nuke bad_branch
43
43
  end
@@ -55,13 +55,12 @@ describe Gitx::Cli::NukeCommand do
55
55
 
56
56
  expect(cli).to receive(:current_build_tag).with(good_branch).and_return(buildtag)
57
57
 
58
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
59
- expect(cli).to receive(:run_cmd).with('git branch -D prototype', allow_failure: true).ordered
60
- expect(cli).to receive(:run_cmd).with('git push origin --delete prototype', allow_failure: true).ordered
61
- expect(cli).to receive(:run_cmd).with('git checkout -b prototype build-master-2013-10-01-01').ordered
62
- expect(cli).to receive(:run_cmd).with('git push origin prototype').ordered
63
- expect(cli).to receive(:run_cmd).with('git branch --set-upstream-to origin/prototype').ordered
64
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
58
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
59
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
60
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'prototype').ordered
61
+ expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'build-master-2013-10-01-01').ordered
62
+ expect(executor).to receive(:execute).with('git', 'share').ordered
63
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
65
64
 
66
65
  cli.nuke 'prototype'
67
66
  end
@@ -77,7 +76,7 @@ describe Gitx::Cli::NukeCommand do
77
76
 
78
77
  expect(cli).to receive(:current_build_tag).with('master').and_return(buildtag)
79
78
 
80
- expect(cli).to_not receive(:run_cmd)
79
+ expect(executor).to_not receive(:execute)
81
80
 
82
81
  cli.nuke 'prototype'
83
82
  end
@@ -95,8 +94,8 @@ describe Gitx::Cli::NukeCommand do
95
94
  let(:bad_branch) { 'prototype' }
96
95
  let(:buildtags) { '' }
97
96
  it 'raises error' do
98
- expect(cli).to receive(:run_cmd).with('git fetch --tags').ordered
99
- expect(cli).to receive(:run_cmd).with("git tag -l 'build-master-*'").and_return(buildtags).ordered
97
+ expect(executor).to receive(:execute).with('git', 'fetch', '--tags').ordered
98
+ expect(executor).to receive(:execute).with('git', 'tag', '--list', 'build-master-*').and_return(buildtags).ordered
100
99
 
101
100
  expect { cli.nuke('prototype') }.to raise_error(/No known good tag found for branch/)
102
101
  end
@@ -115,7 +114,7 @@ describe Gitx::Cli::NukeCommand do
115
114
 
116
115
  expect(cli).to receive(:ask).and_return(good_branch)
117
116
  expect(cli).to receive(:yes?).with('Reset prototype to build-master-2013-10-01-01? (y/n)', :green).and_return(true)
118
- expect(cli).to receive(:run_cmd).with('git diff build-master-2013-10-01-01...prototype --name-only db/migrate').and_return(migrations)
117
+ expect(executor).to receive(:execute).with('git', 'diff', 'build-master-2013-10-01-01...prototype', '--name-only', 'db/migrate').and_return(migrations)
119
118
  expect(cli).to receive(:yes?).with('Are you sure you want to nuke prototype? (y/n) ', :green).and_return(false)
120
119
 
121
120
  cli.nuke 'prototype'
@@ -141,16 +140,15 @@ describe Gitx::Cli::NukeCommand do
141
140
 
142
141
  expect(cli).to receive(:ask).and_return(good_branch)
143
142
  expect(cli).to receive(:yes?).with('Reset prototype to build-master-2013-10-01-01? (y/n)', :green).and_return(true)
144
- expect(cli).to receive(:run_cmd).with('git diff build-master-2013-10-01-01...prototype --name-only db/migrate').and_return(migrations)
143
+ expect(executor).to receive(:execute).with('git', 'diff', 'build-master-2013-10-01-01...prototype', '--name-only', 'db/migrate').and_return(migrations)
145
144
  expect(cli).to receive(:yes?).with('Are you sure you want to nuke prototype? (y/n) ', :green).and_return(true)
146
145
 
147
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
148
- expect(cli).to receive(:run_cmd).with('git branch -D prototype', allow_failure: true).ordered
149
- expect(cli).to receive(:run_cmd).with('git push origin --delete prototype', allow_failure: true).ordered
150
- expect(cli).to receive(:run_cmd).with('git checkout -b prototype build-master-2013-10-01-01').ordered
151
- expect(cli).to receive(:run_cmd).with('git push origin prototype').ordered
152
- expect(cli).to receive(:run_cmd).with('git branch --set-upstream-to origin/prototype').ordered
153
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
146
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
147
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
148
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'prototype').ordered
149
+ expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'build-master-2013-10-01-01').ordered
150
+ expect(executor).to receive(:execute).with('git', 'share').ordered
151
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
154
152
 
155
153
  cli.nuke 'prototype'
156
154
  end
@@ -13,6 +13,7 @@ describe Gitx::Cli::ReleaseCommand do
13
13
  let(:branch) { double('fake branch', name: 'feature-branch') }
14
14
  let(:authorization_token) { '123123' }
15
15
  let(:repo) { cli.send(:repo) }
16
+ let(:executor) { cli.send(:executor) }
16
17
 
17
18
  before do
18
19
  allow(cli).to receive(:current_branch).and_return(branch)
@@ -22,7 +23,7 @@ describe Gitx::Cli::ReleaseCommand do
22
23
  context 'when user rejects release' do
23
24
  before do
24
25
  expect(cli).to receive(:yes?).and_return(false)
25
- expect(cli).to_not receive(:run_cmd)
26
+ expect(executor).to_not receive(:execute)
26
27
 
27
28
  cli.release
28
29
  end
@@ -33,16 +34,16 @@ describe Gitx::Cli::ReleaseCommand do
33
34
  context 'when user confirms release and pull request exists with non-success status' do
34
35
  before do
35
36
  expect(repo).to receive(:workdir).and_return(temp_dir)
36
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
37
37
 
38
38
  expect(cli).to receive(:yes?).with('Release feature-branch to master? (y/n)', :green).and_return(true)
39
39
  expect(cli).to receive(:yes?).with('Branch status is currently: failure. Proceed with release? (y/n)', :red).and_return(false)
40
40
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
41
41
 
42
- expect(cli).to_not receive(:run_cmd).with('git checkout master')
43
- expect(cli).to_not receive(:run_cmd).with('git pull origin master')
44
- expect(cli).to_not receive(:run_cmd).with('git merge --no-ff -m "[gitx] Releasing feature-branch to master (Pull request #10)" feature-branch')
45
- expect(cli).to_not receive(:run_cmd).with('git push origin HEAD')
42
+ expect(executor).to receive(:execute).with('git', 'update').ordered
43
+ expect(executor).to_not receive(:execute).with('git', 'checkout', 'master')
44
+ expect(executor).to_not receive(:execute).with('git', 'pull', 'origin', 'master')
45
+ expect(executor).to_not receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Releasing feature-branch to master (Pull request #10)', 'feature-branch')
46
+ expect(executor).to_not receive(:execute).with('git', 'push', 'origin', 'HEAD')
46
47
 
47
48
  VCR.use_cassette('pull_request_does_exist_with_failure_status') do
48
49
  cli.release
@@ -56,17 +57,16 @@ describe Gitx::Cli::ReleaseCommand do
56
57
  before do
57
58
  expect(repo).to receive(:workdir).and_return(temp_dir)
58
59
 
59
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
60
-
61
60
  expect(cli).to receive(:yes?).and_return(true)
62
61
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
63
62
 
64
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
65
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
66
- expect(cli).to receive(:run_cmd).with('git pull origin master').ordered
67
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Releasing feature-branch to master (Pull request #10)" feature-branch').ordered
68
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
69
- expect(cli).to receive(:run_cmd).with('git integrate').ordered
63
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
64
+ expect(executor).to receive(:execute).with('git', 'update').ordered
65
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
66
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
67
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Releasing feature-branch to master (Pull request #10)', 'feature-branch').ordered
68
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
69
+ expect(executor).to receive(:execute).with('git integrate').ordered
70
70
 
71
71
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
72
72
  cli.release
@@ -87,17 +87,16 @@ describe Gitx::Cli::ReleaseCommand do
87
87
  File.open(File.join(temp_dir, '.gitx.yml'), 'w') do |f|
88
88
  f.puts gitx_config.to_yaml
89
89
  end
90
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
91
-
92
90
  expect(cli).to receive(:yes?).and_return(true)
93
91
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
94
92
 
95
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
96
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
97
- expect(cli).to receive(:run_cmd).with('git pull origin master').ordered
98
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Releasing feature-branch to master (Pull request #10)" feature-branch').ordered
99
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
100
- expect(cli).to receive(:run_cmd).with('echo hello').ordered
93
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
94
+ expect(executor).to receive(:execute).with('git', 'update').ordered
95
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
96
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
97
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Releasing feature-branch to master (Pull request #10)', 'feature-branch').ordered
98
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
99
+ expect(executor).to receive(:execute).with('echo hello').ordered
101
100
 
102
101
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
103
102
  cli.release
@@ -110,17 +109,17 @@ describe Gitx::Cli::ReleaseCommand do
110
109
  context 'when target_branch is not nil and user confirms release and pull request exists with success status' do
111
110
  before do
112
111
  expect(repo).to receive(:workdir).and_return(temp_dir)
113
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
114
112
 
115
113
  expect(cli).to receive(:yes?).and_return(true)
116
114
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
117
115
 
118
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
119
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
120
- expect(cli).to receive(:run_cmd).with('git pull origin master').ordered
121
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Releasing feature-branch to master (Pull request #10)" feature-branch').ordered
122
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
123
- expect(cli).to receive(:run_cmd).with('git integrate').ordered
116
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
117
+ expect(executor).to receive(:execute).with('git', 'update').ordered
118
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
119
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
120
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Releasing feature-branch to master (Pull request #10)', 'feature-branch').ordered
121
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
122
+ expect(executor).to receive(:execute).with('git integrate').ordered
124
123
 
125
124
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
126
125
  cli.release 'feature-branch'
@@ -146,19 +145,19 @@ describe Gitx::Cli::ReleaseCommand do
146
145
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
147
146
  allow(cli).to receive(:ask_editor).and_return('description')
148
147
 
149
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update).twice
150
-
151
148
  expect(cli).to receive(:yes?).with('Release feature-branch to master? (y/n)', :green).and_return(true)
152
149
  expect(cli).to receive(:yes?).with('Branch status is currently: pending. Proceed with release? (y/n)', :red).and_return(true)
153
150
 
154
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
155
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
156
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %B'").and_return('2013-01-01 did some stuff').ordered
157
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
158
- expect(cli).to receive(:run_cmd).with('git pull origin master').ordered
159
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Releasing feature-branch to master (Pull request #10)" feature-branch').ordered
160
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
161
- expect(cli).to receive(:run_cmd).with('git integrate').ordered
151
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
152
+ expect(executor).to receive(:execute).with('git', 'update').ordered
153
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
154
+ expect(executor).to receive(:execute).with('git', 'update').ordered
155
+ expect(executor).to receive(:execute).with('git', 'log', 'master...feature-branch', '--reverse', '--no-merges', "--pretty=format:'* %B'").and_return('2013-01-01 did some stuff').ordered
156
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
157
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
158
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Releasing feature-branch to master (Pull request #10)', 'feature-branch').ordered
159
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
160
+ expect(executor).to receive(:execute).with('git integrate').ordered
162
161
 
163
162
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls').to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
164
163
  VCR.use_cassette('pull_request_does_not_exist') do
@@ -180,18 +179,18 @@ describe Gitx::Cli::ReleaseCommand do
180
179
  end
181
180
  before do
182
181
  expect(repo).to receive(:workdir).and_return(temp_dir)
183
- expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
184
182
 
185
183
  expect(cli).to receive(:yes?).and_return(true)
186
184
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
187
185
 
188
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
189
- expect(cli).to receive(:run_cmd).with('git checkout master').ordered
190
- expect(cli).to receive(:run_cmd).with('git pull origin master').ordered
191
- expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Releasing feature-branch to master (Pull request #10)" feature-branch').ordered
192
- expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
193
- expect(cli).to receive(:run_cmd).with('git integrate').ordered
194
- expect(cli).to receive(:run_cmd).with('git cleanup').ordered
186
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
187
+ expect(executor).to receive(:execute).with('git', 'update').ordered
188
+ expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
189
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
190
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Releasing feature-branch to master (Pull request #10)', 'feature-branch').ordered
191
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
192
+ expect(executor).to receive(:execute).with('git integrate').ordered
193
+ expect(executor).to receive(:execute).with('git cleanup').ordered
195
194
 
196
195
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
197
196
  cli.release