Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
77f10d55
Commit
77f10d55
authored
Aug 08, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly set the expectation on the main object
parent
5d963fcc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
19 deletions
+23
-19
spec/support/rake_helpers.rb
spec/support/rake_helpers.rb
+7
-3
spec/tasks/gitlab/gitaly_rake_spec.rb
spec/tasks/gitlab/gitaly_rake_spec.rb
+8
-8
spec/tasks/gitlab/workhorse_rake_spec.rb
spec/tasks/gitlab/workhorse_rake_spec.rb
+8
-8
No files found.
spec/support/rake_helpers.rb
View file @
77f10d55
...
@@ -5,11 +5,15 @@ module RakeHelpers
...
@@ -5,11 +5,15 @@ module RakeHelpers
end
end
def
stub_warn_user_is_not_gitlab
def
stub_warn_user_is_not_gitlab
allow
_any_instance_of
(
O
bject
).
to
receive
(
:warn_user_is_not_gitlab
)
allow
(
main_o
bject
).
to
receive
(
:warn_user_is_not_gitlab
)
end
end
def
silence_output
def
silence_output
allow
(
$stdout
).
to
receive
(
:puts
)
allow
(
main_object
).
to
receive
(
:puts
)
allow
(
$stdout
).
to
receive
(
:print
)
allow
(
main_object
).
to
receive
(
:print
)
end
def
main_object
@main_object
||=
TOPLEVEL_BINDING
.
eval
(
'self'
)
end
end
end
end
spec/tasks/gitlab/gitaly_rake_spec.rb
View file @
77f10d55
...
@@ -20,7 +20,7 @@ describe 'gitlab:gitaly namespace rake task' do
...
@@ -20,7 +20,7 @@ describe 'gitlab:gitaly namespace rake task' do
context
'when an underlying Git command fail'
do
context
'when an underlying Git command fail'
do
it
'aborts and display a help message'
do
it
'aborts and display a help message'
do
expect
_any_instance_of
(
O
bject
)
expect
(
main_o
bject
)
.
to
receive
(
:checkout_or_clone_version
).
and_raise
'Git error'
.
to
receive
(
:checkout_or_clone_version
).
and_raise
'Git error'
expect
{
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
}.
to
raise_error
'Git error'
expect
{
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
}.
to
raise_error
'Git error'
...
@@ -33,7 +33,7 @@ describe 'gitlab:gitaly namespace rake task' do
...
@@ -33,7 +33,7 @@ describe 'gitlab:gitaly namespace rake task' do
end
end
it
'calls checkout_or_clone_version with the right arguments'
do
it
'calls checkout_or_clone_version with the right arguments'
do
expect
_any_instance_of
(
O
bject
)
expect
(
main_o
bject
)
.
to
receive
(
:checkout_or_clone_version
).
with
(
version:
version
,
repo:
repo
,
target_dir:
clone_path
)
.
to
receive
(
:checkout_or_clone_version
).
with
(
version:
version
,
repo:
repo
,
target_dir:
clone_path
)
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
...
@@ -58,13 +58,13 @@ describe 'gitlab:gitaly namespace rake task' do
...
@@ -58,13 +58,13 @@ describe 'gitlab:gitaly namespace rake task' do
context
'gmake is available'
do
context
'gmake is available'
do
before
do
before
do
expect
_any_instance_of
(
O
bject
).
to
receive
(
:checkout_or_clone_version
)
expect
(
main_o
bject
).
to
receive
(
:checkout_or_clone_version
)
allow
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'gmake'
]).
and_return
(
true
)
allow
(
main_o
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'gmake'
]).
and_return
(
true
)
end
end
it
'calls gmake in the gitaly directory'
do
it
'calls gmake in the gitaly directory'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
'/usr/bin/gmake'
,
0
])
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
'/usr/bin/gmake'
,
0
])
expect
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'gmake'
]).
and_return
(
true
)
expect
(
main_o
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'gmake'
]).
and_return
(
true
)
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
end
end
...
@@ -72,13 +72,13 @@ describe 'gitlab:gitaly namespace rake task' do
...
@@ -72,13 +72,13 @@ describe 'gitlab:gitaly namespace rake task' do
context
'gmake is not available'
do
context
'gmake is not available'
do
before
do
before
do
expect
_any_instance_of
(
O
bject
).
to
receive
(
:checkout_or_clone_version
)
expect
(
main_o
bject
).
to
receive
(
:checkout_or_clone_version
)
allow
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'make'
]).
and_return
(
true
)
allow
(
main_o
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'make'
]).
and_return
(
true
)
end
end
it
'calls make in the gitaly directory'
do
it
'calls make in the gitaly directory'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
''
,
42
])
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
''
,
42
])
expect
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'make'
]).
and_return
(
true
)
expect
(
main_o
bject
).
to
receive
(
:run_command!
).
with
(
command_preamble
+
[
'make'
]).
and_return
(
true
)
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
run_rake_task
(
'gitlab:gitaly:install'
,
clone_path
)
end
end
...
...
spec/tasks/gitlab/workhorse_rake_spec.rb
View file @
77f10d55
...
@@ -20,7 +20,7 @@ describe 'gitlab:workhorse namespace rake task' do
...
@@ -20,7 +20,7 @@ describe 'gitlab:workhorse namespace rake task' do
context
'when an underlying Git command fail'
do
context
'when an underlying Git command fail'
do
it
'aborts and display a help message'
do
it
'aborts and display a help message'
do
expect
_any_instance_of
(
O
bject
)
expect
(
main_o
bject
)
.
to
receive
(
:checkout_or_clone_version
).
and_raise
'Git error'
.
to
receive
(
:checkout_or_clone_version
).
and_raise
'Git error'
expect
{
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
}.
to
raise_error
'Git error'
expect
{
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
}.
to
raise_error
'Git error'
...
@@ -33,7 +33,7 @@ describe 'gitlab:workhorse namespace rake task' do
...
@@ -33,7 +33,7 @@ describe 'gitlab:workhorse namespace rake task' do
end
end
it
'calls checkout_or_clone_version with the right arguments'
do
it
'calls checkout_or_clone_version with the right arguments'
do
expect
_any_instance_of
(
O
bject
)
expect
(
main_o
bject
)
.
to
receive
(
:checkout_or_clone_version
).
with
(
version:
version
,
repo:
repo
,
target_dir:
clone_path
)
.
to
receive
(
:checkout_or_clone_version
).
with
(
version:
version
,
repo:
repo
,
target_dir:
clone_path
)
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
...
@@ -48,13 +48,13 @@ describe 'gitlab:workhorse namespace rake task' do
...
@@ -48,13 +48,13 @@ describe 'gitlab:workhorse namespace rake task' do
context
'gmake is available'
do
context
'gmake is available'
do
before
do
before
do
expect
_any_instance_of
(
O
bject
).
to
receive
(
:checkout_or_clone_version
)
expect
(
main_o
bject
).
to
receive
(
:checkout_or_clone_version
)
allow
_any_instance_of
(
Object
).
to
receive
(
:run_command!
).
with
([
'gmake'
]).
and_return
(
true
)
allow
(
Object
).
to
receive
(
:run_command!
).
with
([
'gmake'
]).
and_return
(
true
)
end
end
it
'calls gmake in the gitlab-workhorse directory'
do
it
'calls gmake in the gitlab-workhorse directory'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
'/usr/bin/gmake'
,
0
])
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
'/usr/bin/gmake'
,
0
])
expect
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
([
'gmake'
]).
and_return
(
true
)
expect
(
main_o
bject
).
to
receive
(
:run_command!
).
with
([
'gmake'
]).
and_return
(
true
)
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
end
end
...
@@ -62,13 +62,13 @@ describe 'gitlab:workhorse namespace rake task' do
...
@@ -62,13 +62,13 @@ describe 'gitlab:workhorse namespace rake task' do
context
'gmake is not available'
do
context
'gmake is not available'
do
before
do
before
do
expect
_any_instance_of
(
O
bject
).
to
receive
(
:checkout_or_clone_version
)
expect
(
main_o
bject
).
to
receive
(
:checkout_or_clone_version
)
allow
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
([
'make'
]).
and_return
(
true
)
allow
(
main_o
bject
).
to
receive
(
:run_command!
).
with
([
'make'
]).
and_return
(
true
)
end
end
it
'calls make in the gitlab-workhorse directory'
do
it
'calls make in the gitlab-workhorse directory'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
''
,
42
])
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w[which gmake]
).
and_return
([
''
,
42
])
expect
_any_instance_of
(
O
bject
).
to
receive
(
:run_command!
).
with
([
'make'
]).
and_return
(
true
)
expect
(
main_o
bject
).
to
receive
(
:run_command!
).
with
([
'make'
]).
and_return
(
true
)
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
run_rake_task
(
'gitlab:workhorse:install'
,
clone_path
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment