spec/cfoundry/v2/app_event_spec.rb in cfoundry-1.5.3 vs spec/cfoundry/v2/app_event_spec.rb in cfoundry-2.0.0

- old
+ new

@@ -1,78 +1,82 @@ require "spec_helper" -describe CFoundry::V2::AppEvent do - let(:client) { fake_client } +module CFoundry + module V2 + describe AppEvent do + let(:app) { build(:app) } + let(:app_event) { build(:app_event, :app => app) } - let(:app) { fake :app } + it "has an app" do + expect(app_event.app).to eq(app) + end - subject { described_class.new("app-event-1", client) } + describe "#instance_guid" do + it "has an instance guid" do + app_event.instance_guid = "foo" + expect(app_event.instance_guid).to eq("foo") + end - it "has an app" do - subject.app = app - expect(subject.app).to eq(app) - end - - describe "#instance_guid" do - it "has an instance guid" do - subject.instance_guid = "foo" - expect(subject.instance_guid).to eq("foo") - end - - context "when an invalid value is assigned" do - it "raises a Mismatch exception" do - expect { - subject.instance_guid = 123 - }.to raise_error(CFoundry::Mismatch) + context "when an invalid value is assigned" do + it "raises a Mismatch exception" do + expect { + app_event.instance_guid = 123 + }.to raise_error(Mismatch) + end + end end - end - end - describe "#instance_index" do - it "has an instance index" do - subject.instance_index = 123 - expect(subject.instance_index).to eq(123) - end + describe "#instance_index" do + it "has an instance index" do + app_event.instance_index = 123 + expect(app_event.instance_index).to eq(123) + end - context "when an invalid value is assigned" do - it "raises a Mismatch exception" do - expect { - subject.instance_index = "wrong" - }.to raise_error(CFoundry::Mismatch) + context "when an invalid value is assigned" do + it "raises a Mismatch exception" do + expect { + app_event.instance_index = "wrong" + }.to raise_error(Mismatch) + end + end end - end - end - describe "#exit_status" do - it "has an instance index" do - subject.exit_status = 123 - expect(subject.exit_status).to eq(123) - end + describe "#exit_status" do + it "has an instance index" do + app_event.exit_status = 123 + expect(app_event.exit_status).to eq(123) + end - context "when an invalid value is assigned" do - it "raises a Mismatch exception" do - expect { - subject.exit_status = "wrong" - }.to raise_error(CFoundry::Mismatch) + context "when an invalid value is assigned" do + it "raises a Mismatch exception" do + expect { + app_event.exit_status = "wrong" + }.to raise_error(Mismatch) + end + end end - end - end - describe "#exit_description" do - it "defaults to an empty string" do - expect(subject.fake.exit_description).to eq("") - end + describe "#exit_description" do + before do + stub_request(:get, /v2\/app_events\/.*/).to_return(:body => {:entity => {}}.to_json) + end - it "has an instance guid" do - subject.exit_description = "foo" - expect(subject.exit_description).to eq("foo") - end + it "defaults to an empty string" do + expect(app_event.exit_description).to eq("") + end - context "when an invalid value is assigned" do - it "raises a Mismatch exception" do - expect { - subject.exit_description = 123 - }.to raise_error(CFoundry::Mismatch) + it "has an instance guid" do + app_event.exit_description = "foo" + expect(app_event.exit_description).to eq("foo") + end + + context "when an invalid value is assigned" do + it "raises a Mismatch exception" do + expect { + app_event.exit_description = 123 + }.to raise_error(Mismatch) + end + end end end end end