diff options
Diffstat (limited to 'spec/gitlab_keys_spec.rb')
-rw-r--r-- | spec/gitlab_keys_spec.rb | 21 |
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) |