gitlab-org--gitlab-foss/spec/lib/gitlab/popen_spec.rb
Dmitriy Zaporozhets f40b99d02e
Merge branch 'master' into rubocop-for-tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	spec/features/issues_spec.rb
	spec/models/forked_project_link_spec.rb
	spec/models/hooks/service_hook_spec.rb
	spec/models/hooks/web_hook_spec.rb
	spec/models/project_services/hipchat_service_spec.rb
	spec/requests/api/project_members_spec.rb
	spec/requests/api/projects_spec.rb
	spec/requests/api/system_hooks_spec.rb
	spec/services/archive_repository_service_spec.rb
	spec/support/matchers.rb
	spec/tasks/gitlab/backup_rake_spec.rb
2015-06-23 10:44:03 +02:00

43 lines
1 KiB
Ruby

require 'spec_helper'
describe 'Gitlab::Popen', no_db: true do
let(:path) { Rails.root.join('tmp').to_s }
before do
@klass = Class.new(Object)
@klass.send(:include, Gitlab::Popen)
end
context 'zero status' do
before do
@output, @status = @klass.new.popen(%W(ls), path)
end
it { expect(@status).to be_zero }
it { expect(@output).to include('cache') }
end
context 'non-zero status' do
before do
@output, @status = @klass.new.popen(%W(cat NOTHING), path)
end
it { expect(@status).to eq(1) }
it { expect(@output).to include('No such file or directory') }
end
context 'unsafe string command' do
it 'raises an error when it gets called with a string argument' do
expect { @klass.new.popen('ls', path) }.to raise_error(RuntimeError)
end
end
context 'without a directory argument' do
before do
@output, @status = @klass.new.popen(%W(ls))
end
it { expect(@status).to be_zero }
it { expect(@output).to include('spec') }
end
end