示例#1
0
					expectedError := errors.New(fmt.Sprintf("gpio write error"))
					fakeGpio.WriteLowReturns(expectedError)

					expectedLightState.StateKnown = false
					expectedLightState.LightOn = false
					expectedLightState.ErrorMsg = expectedError.Error()
					expectedReturn, err = json.Marshal(expectedLightState)
					Expect(err).NotTo(HaveOccurred())
				})

				It("Should write low to light pin", func() {
					lh.HandleSet(fakeResponseWriter, dummyRequest)

					Expect(fakeGpio.WriteLowCallCount()).To(Equal(1))

					actualGpioPin := fakeGpio.WriteLowArgsForCall(0)
					Expect(actualGpioPin).To(Equal(gpioLightPin))
				})

				It("Should return light state unknown", func() {
					lh.HandleSet(fakeResponseWriter, dummyRequest)
					Expect(fakeResponseWriter.WriteCallCount()).To(Equal(1))
					Expect(fakeResponseWriter.WriteArgsForCall(0)).To(Equal(expectedReturn))
				})
			})

			Context("When turning off light command return sucessfully", func() {
				It("Should write low to light pin", func() {
					lh.HandleSet(fakeResponseWriter, dummyRequest)

					Expect(fakeGpio.WriteLowCallCount()).To(Equal(1))