} }) Describe("Create", func() { Context("when retrieving the number of instances fails", func() { BeforeEach(func() { localInstanceCreator.LocalInstanceRepository = &fakes.FakeLocalRepository{ DeletedInstanceIds: []string{}, CreatedInstances: []*redis.Instance{}, Instances: []*redis.Instance{}, InstanceCountErr: errors.New("could not retrieve instance count"), } }) It("should return an error if unable to retrieve instance count", func() { err := localInstanceCreator.Create(instanceID) Ω(err).To(HaveOccurred()) }) }) Context("when the service instance limit has not been met", func() { BeforeEach(func() { freePortsFound = 0 }) It("finds a free port", func() { err := localInstanceCreator.Create(instanceID) Ω(err).ToNot(HaveOccurred()) Ω(freePortsFound).To(Equal(1)) })