}) Context("when the file specified has valid json", func() { BeforeEach(func() { tempFile.Write([]byte(`[{"protocol":"udp","ports":"8080-9090","destination":"198.41.191.47/1"}]`)) }) It("displays a message describing what its going to do", func() { Expect(ui.Outputs).To(ContainSubstrings( []string{"Creating security group", "my-group", "my-user"}, []string{"OK"}, )) }) It("creates the security group with those rules", func() { _, rules := securityGroupRepo.CreateArgsForCall(0) Expect(rules).To(Equal([]map[string]interface{}{ {"protocol": "udp", "ports": "8080-9090", "destination": "198.41.191.47/1"}, })) }) 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.CreateReturns(errors.New("Wops I failed")) }) It("fails loudly", func() { Expect(ui.Outputs).To(ContainSubstrings( []string{"Creating security group", "my-group"}, []string{"FAILED"},