}) It("updates the security group with those rules, obviously", func() { jsonData := []map[string]interface{}{ {"protocol": "udp", "port": "8080-9090", "destination": "198.41.191.47/1"}, } _, jsonArg := securityGroupRepo.UpdateArgsForCall(0) Expect(jsonArg).To(Equal(jsonData)) }) Context("when the API returns an error", func() { Context("some sort of awful terrible error that we were not prescient enough to anticipate", func() { BeforeEach(func() { securityGroupRepo.UpdateReturns(errors.New("Wops I failed")) }) It("fails loudly", func() { Expect(ui.Outputs()).To(ContainSubstrings( []string{"Updating security group", "my-group-name"}, []string{"FAILED"}, )) }) }) }) Context("when the file specified has invalid json", func() { BeforeEach(func() { tempFile.Write([]byte(`[{noquote: thiswontwork}]`)) })