Skip to content

Commit

Permalink
Clean up specs
Browse files Browse the repository at this point in the history
  • Loading branch information
fschueller committed Apr 6, 2017
1 parent 8b2e24b commit bf5f203
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions spec/connect/client_spec.rb
Expand Up @@ -404,36 +404,41 @@
)
end

before { SUSE::Connect::GlobalLogger.instance.log = string_logger }

context 'when system is registered' do
before do
allow(subject).to receive_messages(system_auth: 'Basic: encodedstring')
allow(subject).to receive(:registered?).and_return true
allow(subject.api).to receive(:deregister).with('Basic: encodedstring').and_return stubbed_response
end

it 'calls underlying api and removes credentials file' do
expect(subject.api).to receive(:deregister).with('Basic: encodedstring').and_return stubbed_response
expect(System).to receive(:cleanup!).and_return(true)
subject.deregister!
end

it 'cleans up system' do
expect(System).to receive(:cleanup!).and_return(true)
subject.deregister!
end

it 'prints confirmation message on successful deregistration' do
allow(subject.api).to receive(:deregister).with('Basic: encodedstring').and_return stubbed_response
allow(System).to receive(:cleanup!).and_return(true)
SUSE::Connect::GlobalLogger.instance.log = string_logger
expect(string_logger).to receive(:info).with('Successfully deregistered system.')
context 'when system is cleaned up' do
before do
allow(System).to receive(:cleanup!).and_return(true)
end

subject.deregister!
it 'prints confirmation message' do
expect(string_logger).to receive(:info).with('Successfully deregistered system.')
subject.deregister!
end
end
end

context 'when system is not registered' do
before do
allow(subject).to receive(:registered?).and_return false
end
before { allow(subject).to receive(:registered?).and_return false }

it 'prints warning when system was not registered before' do
SUSE::Connect::GlobalLogger.instance.log = string_logger
it 'prints a warning' do
expect(string_logger).to receive(:fatal).with('Deregistration failed. Check if the system has been '\
'registered using the -s option or use the --regcode parameter to register it.')
subject.deregister!
Expand Down

0 comments on commit bf5f203

Please sign in to comment.