spec/lib/flapjack/gateways/api/entity_methods_spec.rb in flapjack-0.8.10 vs spec/lib/flapjack/gateways/api/entity_methods_spec.rb in flapjack-0.8.11
- old
+ new
@@ -13,11 +13,11 @@
let(:entity_name) { 'www.example.net'}
let(:entity_name_esc) { URI.escape(entity_name) }
let(:check) { 'ping' }
let(:entity_presenter) { double(Flapjack::Gateways::API::EntityPresenter) }
- let(:entity_check_presenter) { double(Flapjack::Gateways::API::EntityCheckPresenter) }
+ let(:check_presenter) { double(Flapjack::Gateways::API::EntityCheckPresenter) }
let(:redis) { double(::Redis) }
before(:all) do
Flapjack::Gateways::API.class_eval {
@@ -68,14 +68,14 @@
expect(last_response).to be_forbidden
end
it "returns the status for a check on an entity" do
status = double('status', :to_json => 'status!'.to_json)
- expect(entity_check_presenter).to receive(:status).and_return(status)
+ expect(check_presenter).to receive(:status).and_return(status)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
@@ -137,13 +137,13 @@
expect(last_response.body).to eq([{:check => check, :scheduled_maintenance => sched}].to_json)
end
it "returns a list of scheduled maintenance periods for a check on an entity" do
sched = double('sched', :to_json => 'sched!'.to_json)
- expect(entity_check_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(sched)
+ expect(check_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(sched)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
with(entity_name, :redis => redis).and_return(entity)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
@@ -181,13 +181,13 @@
expect(last_response.body).to eq([{:check => check, :unscheduled_maintenance => unsched}].to_json)
end
it "returns a list of unscheduled maintenance periods for a check on an entity" do
unsched = double('unsched', :to_json => 'unsched!'.to_json)
- expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(unsched)
+ expect(check_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(unsched)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
with(entity_name, :redis => redis).and_return(entity)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
@@ -199,13 +199,13 @@
it "returns a list of unscheduled maintenance periods within a time window for a check an entity" do
start = Time.parse('1 Jan 2012')
finish = Time.parse('6 Jan 2012')
unsched = double('unsched', :to_json => 'unsched!'.to_json)
- expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(unsched)
+ expect(check_presenter).to receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(unsched)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
with(entity_name, :redis => redis).and_return(entity)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
@@ -229,13 +229,13 @@
expect(last_response.body).to eq([{:check => check, :outages => out}].to_json)
end
it "returns a list of outages for a check on an entity" do
out = double('out', :to_json => 'out!'.to_json)
- expect(entity_check_presenter).to receive(:outages).with(nil, nil).and_return(out)
+ expect(check_presenter).to receive(:outages).with(nil, nil).and_return(out)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
with(entity_name, :redis => redis).and_return(entity)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
@@ -258,13 +258,13 @@
expect(last_response.body).to eq([{:check => check, :downtime => down}].to_json)
end
it "returns a list of downtimes for a check on an entity" do
down = double('down', :to_json => 'down!'.to_json)
- expect(entity_check_presenter).to receive(:downtime).with(nil, nil).and_return(down)
+ expect(check_presenter).to receive(:downtime).with(nil, nil).and_return(down)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
with(entity_name, :redis => redis).and_return(entity)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
@@ -318,14 +318,14 @@
end
it "returns the status for a check on an entity" do
status = double('status')
result = [{:entity => entity_name, :check => check, :status => status}]
- expect(entity_check_presenter).to receive(:status).and_return(status)
+ expect(check_presenter).to receive(:status).and_return(status)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
@@ -489,14 +489,14 @@
it "returns a list of scheduled maintenance periods for a check on an entity" do
sm = double('sched_maint')
result = [{:entity => entity_name, :check => check, :scheduled_maintenances => sm}]
- expect(entity_check_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(sm)
+ expect(check_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(sm)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
@@ -526,14 +526,14 @@
it "returns a list of unscheduled maintenance periods for a check on an entity" do
um = double('unsched_maint')
result = [{:entity => entity_name, :check => check, :unscheduled_maintenances => um}]
- expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(um)
+ expect(check_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(um)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
@@ -549,14 +549,14 @@
finish = Time.parse('6 Jan 2012')
um = double('unsched_maint')
result = [{:entity => entity_name, :check => check, :unscheduled_maintenances => um}]
- expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(um)
+ expect(check_presenter).to receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(um)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
@@ -615,14 +615,14 @@
it "returns a list of outages for a check on an entity" do
outages = double('outages')
result = [{:entity => entity_name, :check => check, :outages => outages}]
- expect(entity_check_presenter).to receive(:outages).with(nil, nil).and_return(outages)
+ expect(check_presenter).to receive(:outages).with(nil, nil).and_return(outages)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).
@@ -652,13 +652,13 @@
it "returns a list of downtimes for a check on an entity" do
downtime = double('downtime')
result = [{:entity => entity_name, :check => check, :downtime => downtime}]
- expect(entity_check_presenter).to receive(:downtime).with(nil, nil).and_return(downtime)
+ expect(check_presenter).to receive(:downtime).with(nil, nil).and_return(downtime)
expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
- with(entity_check).and_return(entity_check_presenter)
+ with(entity_check).and_return(check_presenter)
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
with(entity, check, :redis => redis).and_return(entity_check)
expect(Flapjack::Data::Entity).to receive(:find_by_name).