(maint) repair incorrect test

The mockist version of the test allows redis' scard to return nil, which
it does not actually do in real life. Verified the behavior in the code
via a debugger. Fixed the test.
This commit is contained in:
Rick Bradley 2016-06-02 12:10:34 -05:00
parent c30c7ac26b
commit 9af40db8b3

View file

@ -79,19 +79,15 @@ describe Vmpooler::API do
expect(last_response.body).to eq(JSON.pretty_generate(json_hash)) expect(last_response.body).to eq(JSON.pretty_generate(json_hash))
expect(last_response.header['Content-Type']).to eq('application/json') expect(last_response.header['Content-Type']).to eq('application/json')
end end
end end
context 'with history param' do context 'with history param' do
it 'returns JSON with null history when redis does not has values' do it 'returns JSON with zeroed history when redis does not have values' do
allow(redis).to receive(:scard)
expect(redis).to receive(:scard).exactly(4).times
get '/dashboard/stats/vmpooler/pool', :history => true get '/dashboard/stats/vmpooler/pool', :history => true
json_hash = { json_hash = {
pool1: {size: 5, ready: nil, history: [nil]}, pool1: {size: 5, ready: 0, history: [0]},
pool2: {size: 1, ready: nil, history: [nil]} pool2: {size: 1, ready: 0, history: [0]}
} }
expect(last_response).to be_ok expect(last_response).to be_ok