Commit fb8606f6 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'rs-rspec' into 'master'

Update to RSpec 3

Closes #54

See merge request gitlab-org/gitlab-shell!229
parents 122d84a4 710f7518
source "http://rubygems.org"
source 'https://rubygems.org'
group :development, :test do
gem 'guard', '~> 1.5.0'
gem 'guard-rspec', '~> 2.1.0'
gem 'listen', '~> 0.5.0'
gem 'rspec', '~> 2.0'
gem 'rspec-its', '~> 1.0.0'
gem 'rspec', '~> 3.8.0'
gem 'rubocop', '0.49.1', require: false
gem 'simplecov', '~> 0.9.0', require: false
gem 'vcr', '~> 2.4.0'
gem 'webmock', '~> 1.9.0'
gem 'vcr', '~> 4.0.0'
gem 'webmock', '~> 3.4.0'
end
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
coderay (1.1.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
docile (1.1.5)
guard (1.5.4)
listen (>= 0.4.2)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-rspec (2.1.2)
guard (>= 1.1)
rspec (~> 2.11)
hashdiff (0.3.7)
listen (0.5.3)
lumberjack (1.0.13)
method_source (0.9.0)
multi_json (1.13.1)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.2)
public_suffix (3.0.3)
rainbow (2.2.2)
rake
rake (12.3.1)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (2.99.4)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
......@@ -57,26 +46,23 @@ GEM
multi_json (~> 1.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
thor (0.20.0)
unicode-display_width (1.4.0)
vcr (2.4.0)
webmock (1.9.3)
addressable (>= 2.2.7)
vcr (4.0.0)
webmock (3.4.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
PLATFORMS
ruby
DEPENDENCIES
guard (~> 1.5.0)
guard-rspec (~> 2.1.0)
listen (~> 0.5.0)
rspec (~> 2.0)
rspec-its (~> 1.0.0)
rspec (~> 3.8.0)
rubocop (= 0.49.1)
simplecov (~> 0.9.0)
vcr (~> 2.4.0)
webmock (~> 1.9.0)
vcr (~> 4.0.0)
webmock (~> 3.4.0)
BUNDLED WITH
1.16.3
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
ROOT_PATH = File.expand_path('..', __dir__)
require_relative 'gitlab_config'
......@@ -136,7 +136,7 @@ class GitlabKeys # rubocop:disable Metrics/ClassLength
lock do
$logger.info('Removing key', key_id: @key_id)
open_auth_file('r+') do |f|
while line = f.gets # rubocop:disable Style/AssignmentInCondition
while line = f.gets # rubocop:disable Lint/AssignmentInCondition
next unless line.start_with?("command=\"#{self.class.command_key(@key_id)}\"")
f.seek(-line.length, IO::SEEK_CUR)
# Overwrite the line with #'s. Because the 'line' variable contains
......
......@@ -7,7 +7,7 @@ describe GitlabAccess do
let(:repo_path) { File.join(repository_path, repo_name) + ".git" }
let(:api) do
double(GitlabNet).tap do |api|
api.stub(check_access: GitAccessStatus.new(true,
allow(api).to receive(:check_access).and_return(GitAccessStatus.new(true,
'ok',
gl_repository: 'project-1',
gl_id: 'user-123',
......@@ -20,19 +20,19 @@ describe GitlabAccess do
end
subject do
GitlabAccess.new(nil, repo_path, 'key-123', 'wow', 'ssh').tap do |access|
access.stub(exec_cmd: :exec_called)
access.stub(api: api)
allow(access).to receive(:exec_cmd).and_return(:exec_called)
allow(access).to receive(:api).and_return(api)
end
end
before do
GitlabConfig.any_instance.stub(repos_path: repository_path)
allow_any_instance_of(GitlabConfig).to receive(:repos_path).and_return(repository_path)
end
describe :initialize do
it { subject.repo_path.should == repo_path }
it { subject.changes.should == ['wow'] }
it { subject.protocol.should == 'ssh' }
it { expect(subject.repo_path).to eq(repo_path) }
it { expect(subject.changes).to eq(['wow']) }
it { expect(subject.protocol).to eq('ssh') }
end
describe "#exec" do
......@@ -44,7 +44,7 @@ describe GitlabAccess do
context "access is denied" do
before do
api.stub(check_access: GitAccessStatus.new(
allow(api).to receive(:check_access).and_return(GitAccessStatus.new(
false,
'denied',
gl_repository: nil,
......@@ -64,7 +64,7 @@ describe GitlabAccess do
context "API connection fails" do
before do
api.stub(:check_access).and_raise(GitlabNet::ApiUnreachableError)
allow(api).to receive(:check_access).and_raise(GitlabNet::ApiUnreachableError)
end
it "returns false" do
......
......@@ -9,27 +9,27 @@ describe GitlabConfig do
subject { config.gitlab_url }
before { config.send(:config)['gitlab_url'] = url }
it { should_not be_empty }
it { should eq(url) }
it { is_expected.not_to be_empty }
it { is_expected.to eq(url) }
context 'remove trailing slashes' do
before { config.send(:config)['gitlab_url'] = url + '//' }
it { should eq(url) }
it { is_expected.to eq(url) }
end
end
describe :audit_usernames do
subject { config.audit_usernames }
it("returns false by default") { should eq(false) }
it("returns false by default") { is_expected.to eq(false) }
end
describe :log_format do
subject { config.log_format }
it 'returns "text" by default' do
should eq('text')
is_expected.to eq('text')
end
end
end
......@@ -65,9 +65,9 @@ describe GitlabKeys do
describe :initialize do
let(:gitlab_keys) { build_gitlab_keys('add-key', 'key-741', 'ssh-rsa AAAAB3NzaDAxx2E') }
it { gitlab_keys.key.should == 'ssh-rsa AAAAB3NzaDAxx2E' }
it { gitlab_keys.instance_variable_get(:@command).should == 'add-key' }
it { gitlab_keys.instance_variable_get(:@key_id).should == 'key-741' }
it { expect(gitlab_keys.key).to eq('ssh-rsa AAAAB3NzaDAxx2E') }
it { expect(gitlab_keys.instance_variable_get(:@command)).to eq('add-key') }
it { expect(gitlab_keys.instance_variable_get(:@key_id)).to eq('key-741') }
end
describe :add_key do
......@@ -77,7 +77,7 @@ describe GitlabKeys do
create_authorized_keys_fixture
gitlab_keys.send :add_key
auth_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell key-741\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E"
File.read(tmp_authorized_keys_path).should == "existing content\n#{auth_line}\n"
expect(File.read(tmp_authorized_keys_path)).to eq("existing content\n#{auth_line}\n")
end
context "without file writing" do
......@@ -85,12 +85,12 @@ describe GitlabKeys do
before { create_authorized_keys_fixture }
it "should log an add-key event" do
$logger.should_receive(:info).with("Adding key", {:key_id=>"key-741", :public_key=>"ssh-rsa AAAAB3NzaDAxx2E"})
expect($logger).to receive(:info).with("Adding key", {:key_id=>"key-741", :public_key=>"ssh-rsa AAAAB3NzaDAxx2E"})
gitlab_keys.send :add_key
end
it "should return true" do
gitlab_keys.send(:add_key).should be_truthy
expect(gitlab_keys.send(:add_key)).to be_truthy
end
end
end
......@@ -104,7 +104,7 @@ describe GitlabKeys do
create_authorized_keys_fixture
gitlab_keys.send :add_key
auth_line1 = 'key-741 AAAAB3NzaDAxx2E'
gitlab_keys.send(:list_keys).should == "#{auth_line1}\n"
expect(gitlab_keys.send(:list_keys)).to eq("#{auth_line1}\n")
end
end
......@@ -118,10 +118,7 @@ describe GitlabKeys do
end
it 'outputs the key IDs, separated by newlines' do
output = capture_stdout do
gitlab_keys.send(:list_key_ids)
end
output.should match "1\n2\n3\n9000"
expect { gitlab_keys.send(:list_key_ids) }.to output("1\n2\n3\n9000\n").to_stdout
end
end
......@@ -130,38 +127,38 @@ describe GitlabKeys do
let(:fake_stdin) { StringIO.new("key-12\tssh-dsa ASDFASGADG\nkey-123\tssh-rsa GFDGDFSGSDFG\n", 'r') }
before do
create_authorized_keys_fixture
gitlab_keys.stub(stdin: fake_stdin)
allow(gitlab_keys).to receive(:stdin).and_return(fake_stdin)
end
it "adds lines at the end of the file" do
gitlab_keys.send :batch_add_keys
auth_line1 = "command=\"#{ROOT_PATH}/bin/gitlab-shell key-12\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-dsa ASDFASGADG"
auth_line2 = "command=\"#{ROOT_PATH}/bin/gitlab-shell key-123\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa GFDGDFSGSDFG"
File.read(tmp_authorized_keys_path).should == "existing content\n#{auth_line1}\n#{auth_line2}\n"
expect(File.read(tmp_authorized_keys_path)).to eq("existing content\n#{auth_line1}\n#{auth_line2}\n")
end
context "with invalid input" do
let(:fake_stdin) { StringIO.new("key-12\tssh-dsa ASDFASGADG\nkey-123\tssh-rsa GFDGDFSGSDFG\nfoo\tbar\tbaz\n", 'r') }
it "aborts" do
gitlab_keys.should_receive(:abort)
expect(gitlab_keys).to receive(:abort)
gitlab_keys.send :batch_add_keys
end
end
context "without file writing" do
before do
gitlab_keys.should_receive(:open).and_yield(double(:file, puts: nil, chmod: nil))
expect(gitlab_keys).to receive(:open).and_yield(double(:file, puts: nil, chmod: nil))
end
it "should log an add-key event" do
$logger.should_receive(:info).with("Adding key", key_id: 'key-12', public_key: "ssh-dsa ASDFASGADG")
$logger.should_receive(:info).with("Adding key", key_id: 'key-123', public_key: "ssh-rsa GFDGDFSGSDFG")
expect($logger).to receive(:info).with("Adding key", key_id: 'key-12', public_key: "ssh-dsa ASDFASGADG")
expect($logger).to receive(:info).with("Adding key", key_id: 'key-123', public_key: "ssh-rsa GFDGDFSGSDFG")
gitlab_keys.send :batch_add_keys
end
it "should return true" do
gitlab_keys.send(:batch_add_keys).should be_truthy
expect(gitlab_keys.send(:batch_add_keys)).to be_truthy
end
end
end
......@@ -171,7 +168,7 @@ describe GitlabKeys do
subject { gitlab_keys.send :stdin }
before { $stdin = 1 }
it { should equal(1) }
it { is_expected.to equal(1) }
end
describe :rm_key do
......@@ -187,22 +184,22 @@ describe GitlabKeys do
end
gitlab_keys.send :rm_key
erased_line = delete_line.gsub(/./, '#')
File.read(tmp_authorized_keys_path).should == "existing content\n#{erased_line}\n#{other_line}\n"
expect(File.read(tmp_authorized_keys_path)).to eq("existing content\n#{erased_line}\n#{other_line}\n")
end
context "without file writing" do
before do
gitlab_keys.stub(:open)
gitlab_keys.stub(:lock).and_yield
allow(gitlab_keys).to receive(:open)
allow(gitlab_keys).to receive(:lock).and_yield
end
it "should log an rm-key event" do
$logger.should_receive(:info).with("Removing key", key_id: "key-741")
expect($logger).to receive(:info).with("Removing key", key_id: "key-741")
gitlab_keys.send :rm_key
end
it "should return true" do
gitlab_keys.send(:rm_key).should be_truthy
expect(gitlab_keys.send(:rm_key)).to be_truthy
end
end
......@@ -219,7 +216,7 @@ describe GitlabKeys do
end
gitlab_keys.send :rm_key
erased_line = delete_line.gsub(/./, '#')
File.read(tmp_authorized_keys_path).should == "existing content\n#{erased_line}\n#{other_line}\n"
expect(File.read(tmp_authorized_keys_path)).to eq("existing content\n#{erased_line}\n#{other_line}\n")
end
end
end
......@@ -228,8 +225,8 @@ describe GitlabKeys do
let(:gitlab_keys) { build_gitlab_keys('clear') }
it "should return true" do
gitlab_keys.stub(:open)
gitlab_keys.send(:clear).should be_truthy
allow(gitlab_keys).to receive(:open)
expect(gitlab_keys.send(:clear)).to be_truthy
end
end
......@@ -242,7 +239,7 @@ describe GitlabKeys do
end
it 'returns false if opening raises an exception' do
gitlab_keys.should_receive(:open_auth_file).and_raise("imaginary error")
expect(gitlab_keys).to receive(:open_auth_file).and_raise("imaginary error")
expect(gitlab_keys.exec).to eq(false)
end
......@@ -257,51 +254,51 @@ describe GitlabKeys do
describe :exec do
it 'add-key arg should execute add_key method' do
gitlab_keys = build_gitlab_keys('add-key')
gitlab_keys.should_receive(:add_key)
expect(gitlab_keys).to receive(:add_key)
gitlab_keys.exec
end
it 'batch-add-keys arg should execute batch_add_keys method' do
gitlab_keys = build_gitlab_keys('batch-add-keys')
gitlab_keys.should_receive(:batch_add_keys)
expect(gitlab_keys).to receive(:batch_add_keys)
gitlab_keys.exec
end
it 'rm-key arg should execute rm_key method' do
gitlab_keys = build_gitlab_keys('rm-key')
gitlab_keys.should_receive(:rm_key)
expect(gitlab_keys).to receive(:rm_key)
gitlab_keys.exec
end
it 'clear arg should execute clear method' do
gitlab_keys = build_gitlab_keys('clear')
gitlab_keys.should_receive(:clear)
expect(gitlab_keys).to receive(:clear)
gitlab_keys.exec
end
it 'check-permissions arg should execute check_permissions method' do
gitlab_keys = build_gitlab_keys('check-permissions')
gitlab_keys.should_receive(:check_permissions)
expect(gitlab_keys).to receive(:check_permissions)
gitlab_keys.exec
end
it 'should puts message if unknown command arg' do
gitlab_keys = build_gitlab_keys('change-key')
gitlab_keys.should_receive(:puts).with('not allowed')
expect(gitlab_keys).to receive(:puts).with('not allowed')
gitlab_keys.exec
end
it 'should log a warning on unknown commands' do
gitlab_keys = build_gitlab_keys('nooope')
gitlab_keys.stub(puts: nil)
$logger.should_receive(:warn).with("Attempt to execute invalid gitlab-keys command", command: '"nooope"')
allow(gitlab_keys).to receive(:puts).and_return(nil)
expect($logger).to receive(:warn).with("Attempt to execute invalid gitlab-keys command", command: '"nooope"')
gitlab_keys.exec
end
end
describe :lock do
before do
GitlabKeys.any_instance.stub(lock_file: tmp_lock_file_path)
allow_any_instance_of(GitlabKeys).to receive(:lock_file).and_return(tmp_lock_file_path)
end
it "should raise exception if operation lasts more then timeout" do
......@@ -335,7 +332,7 @@ describe GitlabKeys do
end
thr1.join
$global.should == "foobar"
expect($global).to eq("foobar")
end
end
......@@ -353,7 +350,7 @@ describe GitlabKeys do
def create_authorized_keys_fixture(existing_content: 'existing content')
FileUtils.mkdir_p(File.dirname(tmp_authorized_keys_path))
open(tmp_authorized_keys_path, 'w') { |file| file.puts(existing_content) }
gitlab_keys.stub(auth_file: tmp_authorized_keys_path)
allow(gitlab_keys).to receive(:auth_file).and_return(tmp_authorized_keys_path)
end
def tmp_authorized_keys_path
......
......@@ -16,22 +16,22 @@ describe GitlabLfsAuthentication do
end
describe '#build_from_json' do
it { subject.username.should == 'dzaporozhets' }
it { subject.lfs_token.should == 'wsnys8Zm8Jn7zyhHTAAK' }
it { subject.repository_http_path.should == 'http://gitlab.dev/repo' }
it { expect(subject.username).to eq('dzaporozhets') }
it { expect(subject.lfs_token).to eq('wsnys8Zm8Jn7zyhHTAAK') }
it { expect(subject.repository_http_path).to eq('http://gitlab.dev/repo') }
end
describe '#authentication_payload' do
result = "{\"header\":{\"Authorization\":\"Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL\"},\"href\":\"http://gitlab.dev/repo/info/lfs/\"}"
it { subject.authentication_payload.should eq(result) }
it { expect(subject.authentication_payload).to eq(result) }
it 'should be a proper JSON' do
payload = subject.authentication_payload
json_payload = JSON.parse(payload)
json_payload['header']['Authorization'].should eq('Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL')
json_payload['href'].should eq('http://gitlab.dev/repo/info/lfs/')
expect(json_payload['header']['Authorization']).to eq('Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL')
expect(json_payload['href']).to eq('http://gitlab.dev/repo/info/lfs/')
end
end
end
......@@ -6,8 +6,8 @@ describe :convert_log_level do
subject { convert_log_level :extreme }
it "converts invalid log level to Logger::INFO" do
$stderr.should_receive(:puts).at_least(:once)
should eq(Logger::INFO)
expect($stderr).to receive(:puts).at_least(:once)
is_expected.to eq(Logger::INFO)
end
end
......
This diff is collapsed.
......@@ -31,7 +31,7 @@ describe GitlabPostReceive do
before do
$logger = double('logger').as_null_object # Global vars are bad
GitlabConfig.any_instance.stub(repos_path: repository_path)
allow_any_instance_of(GitlabConfig).to receive(:repos_path).and_return(repository_path)
end
describe "#exec" do
......
This diff is collapsed.
......@@ -6,10 +6,13 @@ describe URI::HTTPUNIX do
uri = URI::parse('http+unix://%2Fpath%2Fto%2Fsocket/img.jpg')
subject { uri }
it { should be_an_instance_of(URI::HTTPUNIX) }
its(:scheme) { should eq('http+unix') }
its(:hostname) { should eq('/path/to/socket') }
its(:path) { should eq('/img.jpg') }
it { is_expected.to be_an_instance_of(URI::HTTPUNIX) }
it 'has the correct attributes' do
expect(subject.scheme).to eq('http+unix')
expect(subject.hostname).to eq('/path/to/socket')
expect(subject.path).to eq('/img.jpg')
end
end
end
......
......@@ -5,8 +5,8 @@ describe NamesHelper do
include NamesHelper
describe :extract_ref_name do
it { extract_ref_name('refs/heads/awesome-feature').should == 'awesome-feature' }
it { extract_ref_name('refs/tags/v2.2.1').should == 'v2.2.1' }
it { extract_ref_name('refs/tags/releases/v2.2.1').should == 'releases/v2.2.1' }
it { expect(extract_ref_name('refs/heads/awesome-feature')).to eq('awesome-feature') }
it { expect(extract_ref_name('refs/tags/v2.2.1')).to eq('v2.2.1') }
it { expect(extract_ref_name('refs/tags/releases/v2.2.1')).to eq('releases/v2.2.1') }
end
end
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
require 'rspec/its'
require 'simplecov'
SimpleCov.start
require 'vcr'
require 'webmock'
require 'webrick'
VCR.configure do |c|
c.cassette_library_dir = 'spec/vcr_cassettes'
c.hook_into :webmock
c.configure_rspec_metadata!
end
require 'gitlab_init'
# 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
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
# 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
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
config.filter_run :focus
def cleanup_shutdown_pipe(shutdown_pipe)
@shutdown_pipe = nil
return if !shutdown_pipe
super(shutdown_pipe)
config.before(:each) do
stub_const('ROOT_PATH', File.expand_path('..', __dir__))
end
end
require 'webrick'
# like WEBrick::HTTPServer, but listens on UNIX socket
class HTTPUNIXServer < WEBrick::HTTPServer
def initialize(config = {})
null_log = WEBrick::Log.new(IO::NULL, 7)
super(config.merge(Logger: null_log, AccessLog: null_log))
end
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
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/vcr_cassettes'
c.hook_into :webmock
c.configure_rspec_metadata!
end
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment