summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2018-08-20 14:34:24 +1000
committerAsh McKenzie <amckenzie@gitlab.com>2018-09-07 15:09:50 +1000
commitddb95f0dd0463b884860238fd250092bffed0e78 (patch)
treedf56735a910d4bf1b98861ea736c3ba475741172
parentb0a526354eb012d2a2d874d22515d20c035ea5d6 (diff)
downloadgitlab-shell-ddb95f0dd0463b884860238fd250092bffed0e78.tar.gz
GitlabConfig, GitlabShell & GitlabKeys spec fixes
GitlabConfig spec was relying upon real config.yml
-rw-r--r--spec/gitlab_config_spec.rb15
-rw-r--r--spec/gitlab_keys_spec.rb2
-rw-r--r--spec/gitlab_shell_spec.rb10
3 files changed, 16 insertions, 11 deletions
diff --git a/spec/gitlab_config_spec.rb b/spec/gitlab_config_spec.rb
index c262116..d12b657 100644
--- a/spec/gitlab_config_spec.rb
+++ b/spec/gitlab_config_spec.rb
@@ -3,29 +3,34 @@ require_relative '../lib/gitlab_config'
describe GitlabConfig do
let(:config) { GitlabConfig.new }
+ let(:config_data) { {} }
- describe :gitlab_url do
+ before { expect(YAML).to receive(:load_file).and_return(config_data) }
+
+ describe '#gitlab_url' do
let(:url) { 'http://test.com' }
+
subject { config.gitlab_url }
- before { config.send(:config)['gitlab_url'] = url }
+
+ before { config_data['gitlab_url'] = 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 + '//' }
+ before { config_data['gitlab_url'] = url + '//' }
it { is_expected.to eq(url) }
end
end
- describe :audit_usernames do
+ describe '#audit_usernames' do
subject { config.audit_usernames }
it("returns false by default") { is_expected.to eq(false) }
end
- describe :log_format do
+ describe '#log_format' do
subject { config.log_format }
it 'returns "text" by default' do
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index 87492d8..f86d00d 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -307,7 +307,7 @@ describe GitlabKeys do
key.send :lock, 1 do
sleep 2
end
- end.to raise_error
+ end.to raise_error(Timeout::Error, 'execution expired')
end
it "should actually lock file" do
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb
index 135a474..22b21fd 100644
--- a/spec/gitlab_shell_spec.rb
+++ b/spec/gitlab_shell_spec.rb
@@ -68,13 +68,13 @@ describe GitlabShell do
allow_any_instance_of(GitlabConfig).to receive(:audit_usernames).and_return(false)
end
- describe :initialize do
+ describe '#initialize' do
let(:ssh_cmd) { 'git-receive-pack' }
it { expect(subject.gl_id).to eq gl_id }
end
- describe :parse_cmd do
+ describe '#parse_cmd' do
describe 'git' do
context 'w/o namespace' do
let(:ssh_args) { %w(git-upload-pack gitlab-ci.git) }
@@ -161,7 +161,7 @@ describe GitlabShell do
end
end
- describe :exec do
+ describe '#exec' do
let(:gitaly_message) do
JSON.dump(
'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' },
@@ -410,7 +410,7 @@ describe GitlabShell do
end
end
- describe :validate_access do
+ describe '#validate_access' do
let(:ssh_cmd) { "git-upload-pack gitlab-ci.git" }
describe 'check access with api' do
@@ -442,7 +442,7 @@ describe GitlabShell do
end
end
- describe :api do
+ describe '#api' do
let(:shell) { GitlabShell.new(gl_id) }
subject { shell.send :api }