spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb in flapjack-1.0.0rc2 vs spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb in flapjack-1.0.0rc3

- old
+ new

@@ -45,12 +45,14 @@ with(time - (4 * 60 * 60)).and_return(nil) ecp = Flapjack::Gateways::JSONAPI::CheckPresenter.new(entity_check) outages = ecp.outage(time - (5 * 60 * 60), time - (2 * 60 * 60)) expect(outages).not_to be_nil - expect(outages).to be_an(Array) - expect(outages.size).to eq(4) + expect(outages).to be_a(Hash) + expect(outages).to have_key(:outages) + expect(outages[:outages]).to be_an(Array) + expect(outages[:outages].size).to eq(4) # TODO check the data in those hashes end it "returns a list of outage hashes with no start and end time set" do @@ -61,12 +63,14 @@ with(time - (4 * 60 * 60)).and_return(nil) ecp = Flapjack::Gateways::JSONAPI::CheckPresenter.new(entity_check) outages = ecp.outage(nil, nil) expect(outages).not_to be_nil - expect(outages).to be_an(Array) - expect(outages.size).to eq(4) + expect(outages).to be_a(Hash) + expect(outages).to have_key(:outages) + expect(outages[:outages]).to be_an(Array) + expect(outages[:outages].size).to eq(4) # TODO check the data in those hashes end it "returns a consolidated list of outage hashes with repeated state events" do @@ -80,12 +84,14 @@ with(time - (4 * 60 * 60)).and_return(nil) ecp = Flapjack::Gateways::JSONAPI::CheckPresenter.new(entity_check) outages = ecp.outage(nil, nil) expect(outages).not_to be_nil - expect(outages).to be_an(Array) - expect(outages.size).to eq(3) + expect(outages).to be_a(Hash) + expect(outages).to have_key(:outages) + expect(outages[:outages]).to be_an(Array) + expect(outages[:outages].size).to eq(3) end it "returns a (small) outage hash for a single state change" do expect(entity_check).to receive(:historical_states). with(nil, nil).and_return([{:state => 'critical', :timestamp => time - (4 * 60 * 60)}]) @@ -93,12 +99,14 @@ with(time - (4 * 60 * 60)).and_return(nil) ecp = Flapjack::Gateways::JSONAPI::CheckPresenter.new(entity_check) outages = ecp.outage(nil, nil) expect(outages).not_to be_nil - expect(outages).to be_an(Array) - expect(outages.size).to eq(1) + expect(outages).to be_a(Hash) + expect(outages).to have_key(:outages) + expect(outages[:outages]).to be_an(Array) + expect(outages[:outages].size).to eq(1) end it "a list of unscheduled maintenances for an entity check" do expect(entity_check).to receive(:maintenances). with(time - (12 * 60 * 60), time, :scheduled => false).and_return(maintenances) @@ -107,12 +115,14 @@ with(nil, time - (12 * 60 * 60), :scheduled => false).and_return([]) ecp = Flapjack::Gateways::JSONAPI::CheckPresenter.new(entity_check) unsched_maint = ecp.unscheduled_maintenance(time - (12 * 60 * 60), time) - expect(unsched_maint).to be_an(Array) - expect(unsched_maint.size).to eq(4) + expect(unsched_maint).to be_a(Hash) + expect(unsched_maint).to have_key(:unscheduled_maintenances) + expect(unsched_maint[:unscheduled_maintenances]).to be_an(Array) + expect(unsched_maint[:unscheduled_maintenances].size).to eq(4) # TODO check the data in those hashes end it "a list of scheduled maintenances for an entity check" do @@ -123,11 +133,13 @@ with(nil, time - (12 * 60 * 60), :scheduled => true).and_return([]) ecp = Flapjack::Gateways::JSONAPI::CheckPresenter.new(entity_check) sched_maint = ecp.scheduled_maintenance(time - (12 * 60 * 60), time) - expect(sched_maint).to be_an(Array) - expect(sched_maint.size).to eq(4) + expect(sched_maint).to be_a(Hash) + expect(sched_maint).to have_key(:scheduled_maintenances) + expect(sched_maint[:scheduled_maintenances]).to be_an(Array) + expect(sched_maint[:scheduled_maintenances].size).to eq(4) # TODO check the data in those hashes end it "returns downtime and percentage for a downtime check" do