Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
nexedi
gitlab-shell
Commits
21182ae6
Commit
21182ae6
authored
Aug 15, 2018
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganize spec_helper; add support files for VCR and HTTPUNIXServer
parent
03055503
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
35 deletions
+40
-35
spec/spec_helper.rb
spec/spec_helper.rb
+4
-35
spec/support/http_unix_server.rb
spec/support/http_unix_server.rb
+29
-0
spec/support/vcr.rb
spec/support/vcr.rb
+7
-0
No files found.
spec/spec_helper.rb
View file @
21182ae6
require
'simplecov'
require
'simplecov'
SimpleCov
.
start
SimpleCov
.
start
require
'vcr'
require
'webmock'
require
'webmock'
require
'webrick'
require
'gitlab_init'
require
'gitlab_init'
VCR
.
configure
do
|
c
|
Dir
[
File
.
expand_path
(
'support/**/*.rb'
,
__dir__
)].
each
{
|
f
|
require
f
}
c
.
cassette_library_dir
=
'spec/vcr_cassettes'
c
.
hook_into
:webmock
c
.
configure_rspec_metadata!
end
RSpec
.
configure
do
|
config
|
RSpec
.
configure
do
|
config
|
config
.
run_all_when_everything_filtered
=
true
config
.
filter_run
:focus
config
.
before
(
:each
)
do
config
.
before
(
:each
)
do
stub_const
(
'ROOT_PATH'
,
File
.
expand_path
(
'..'
,
__dir__
))
stub_const
(
'ROOT_PATH'
,
File
.
expand_path
(
'..'
,
__dir__
))
end
end
end
end
# like WEBrick::HTTPServer, but listens on UNIX socket
class
HTTPUNIXServer
<
WEBrick
::
HTTPServer
def
listen
(
address
,
port
)
socket
=
Socket
.
unix_server_socket
(
address
)
socket
.
autoclose
=
false
server
=
UNIXServer
.
for_fd
(
socket
.
fileno
)
socket
.
close
@listeners
<<
server
end
# Workaround:
# https://bugs.ruby-lang.org/issues/10956
# Affecting Ruby 2.2
# Fix for 2.2 is at https://github.com/ruby/ruby/commit/ab0a64e1
# However, this doesn't work with 2.1. The following should work for both:
def
start
(
&
block
)
@shutdown_pipe
=
IO
.
pipe
shutdown_pipe
=
@shutdown_pipe
super
(
&
block
)
end
def
cleanup_shutdown_pipe
(
shutdown_pipe
)
@shutdown_pipe
=
nil
return
if
!
shutdown_pipe
super
(
shutdown_pipe
)
end
end
spec/support/http_unix_server.rb
0 → 100644
View file @
21182ae6
require
'webrick'
# like WEBrick::HTTPServer, but listens on UNIX socket
class
HTTPUNIXServer
<
WEBrick
::
HTTPServer
def
listen
(
address
,
port
)
socket
=
Socket
.
unix_server_socket
(
address
)
socket
.
autoclose
=
false
server
=
UNIXServer
.
for_fd
(
socket
.
fileno
)
socket
.
close
@listeners
<<
server
end
# Workaround:
# https://bugs.ruby-lang.org/issues/10956
# Affecting Ruby 2.2
# Fix for 2.2 is at https://github.com/ruby/ruby/commit/ab0a64e1
# However, this doesn't work with 2.1. The following should work for both:
def
start
(
&
block
)
@shutdown_pipe
=
IO
.
pipe
shutdown_pipe
=
@shutdown_pipe
super
(
&
block
)
end
def
cleanup_shutdown_pipe
(
shutdown_pipe
)
@shutdown_pipe
=
nil
return
if
!
shutdown_pipe
super
(
shutdown_pipe
)
end
end
spec/support/vcr.rb
0 → 100644
View file @
21182ae6
require
'vcr'
VCR
.
configure
do
|
c
|
c
.
cassette_library_dir
=
'spec/vcr_cassettes'
c
.
hook_into
:webmock
c
.
configure_rspec_metadata!
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