summaryrefslogtreecommitdiff
path: root/spec/gitlab_keys_spec.rb
diff options
context:
space:
mode:
authorash <smashwilson@gmail.com>2013-05-17 01:23:42 +0000
committerash <smashwilson@gmail.com>2013-05-17 01:23:42 +0000
commit15bec2054f8aa66ad0f71748a735c7cb4a199076 (patch)
tree9606bf2203efa238b5c265657377d7c3bff87d6a /spec/gitlab_keys_spec.rb
parent671e86db504708b9a0d2a656454e23dcfd227aac (diff)
downloadgitlab-shell-15bec2054f8aa66ad0f71748a735c7cb4a199076.tar.gz
Add logging specs for gitlab-keys.
Diffstat (limited to 'spec/gitlab_keys_spec.rb')
-rw-r--r--spec/gitlab_keys_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index f04d506..67bc122 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -2,6 +2,10 @@ require_relative 'spec_helper'
require_relative '../lib/gitlab_keys'
describe GitlabKeys do
+ before do
+ $logger = double('logger').as_null_object
+ end
+
describe :initialize do
let(:gitlab_keys) { build_gitlab_keys('add-key', 'key-741', 'ssh-rsa AAAAB3NzaDAxx2E') }
@@ -18,6 +22,11 @@ describe GitlabKeys do
gitlab_keys.should_receive(:system).with(valid_cmd)
gitlab_keys.send :add_key
end
+
+ it "should log an add-key event" do
+ $logger.should_receive(:info).with('Adding key key-741 => "ssh-rsa AAAAB3NzaDAxx2E"')
+ gitlab_keys.send :add_key
+ end
end
describe :rm_key do
@@ -28,6 +37,11 @@ describe GitlabKeys do
gitlab_keys.should_receive(:system).with(valid_cmd)
gitlab_keys.send :rm_key
end
+
+ it "should log an rm-key event" do
+ $logger.should_receive(:info).with('Removing key key-741')
+ gitlab_keys.send :rm_key
+ end
end
describe :exec do
@@ -48,6 +62,13 @@ describe GitlabKeys do
gitlab_keys.should_receive(:puts).with('not allowed')
gitlab_keys.exec
end
+
+ it 'should log an error on unknown commands' do
+ gitlab_keys = build_gitlab_keys('nooope')
+ gitlab_keys.stub(puts: nil)
+ $logger.should_receive(:error).with('Attempt to execute invalid gitlab-keys command "nooope".')
+ gitlab_keys.exec
+ end
end
def build_gitlab_keys(*args)