From 9af40db8b3eb6db1787003f380c1c6def52e56d0 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Thu, 2 Jun 2016 12:10:34 -0500 Subject: [PATCH] (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. --- spec/vmpooler/api_spec.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spec/vmpooler/api_spec.rb b/spec/vmpooler/api_spec.rb index 973e82e..adbc392 100644 --- a/spec/vmpooler/api_spec.rb +++ b/spec/vmpooler/api_spec.rb @@ -79,19 +79,15 @@ describe Vmpooler::API do expect(last_response.body).to eq(JSON.pretty_generate(json_hash)) expect(last_response.header['Content-Type']).to eq('application/json') end - end context 'with history param' do - it 'returns JSON with null history when redis does not has values' do - allow(redis).to receive(:scard) - expect(redis).to receive(:scard).exactly(4).times - + it 'returns JSON with zeroed history when redis does not have values' do get '/dashboard/stats/vmpooler/pool', :history => true json_hash = { - pool1: {size: 5, ready: nil, history: [nil]}, - pool2: {size: 1, ready: nil, history: [nil]} + pool1: {size: 5, ready: 0, history: [0]}, + pool2: {size: 1, ready: 0, history: [0]} } expect(last_response).to be_ok