Skip to content

Commit

Permalink
Merge pull request #119 from svdasein/master
Browse files Browse the repository at this point in the history
Add spec to ensure that Client.logout is callable
  • Loading branch information
svdasein authored Apr 3, 2021
2 parents e80fe7a + b8c0adb commit 2ed1b59
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion spec/zabbixapi/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@
end
end

describe '.logout' do
subject { client_mock.logout() }
before do
allow_any_instance_of(ZabbixApi::Client).to receive(:api_version).and_return('5.2.2')
allow_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.login',
params: {
user: nil,
password: nil
}
)
allow_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.logout'
)
end
it 'revokes auth using api request' do
expect_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.logout',
params: []
)
subject
end
end

describe '.initialize' do
subject { client_mock }

Expand All @@ -92,6 +116,10 @@
password: nil
}
)
allow_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.logout',
params: {}
)
end

context 'when proxy is provided and no_proxy flag is false' do
Expand Down Expand Up @@ -228,7 +256,7 @@
end
end

context 'when method is not `apiinfo.version` or `user.login`' do
context 'when method is not `apiinfo.version` or `user.login` or `user.logout`' do
let(:method) { 'fakemethod' }
let(:message) do
{
Expand Down

0 comments on commit 2ed1b59

Please sign in to comment.