コード例 #1
0
ファイル: light_test.go プロジェクト: robdimsdale/garagepi
		Context("When attempting to set state without state information", func() {
			BeforeEach(func() {
				u, err := url.Parse("/?state")
				Expect(err).ShouldNot(HaveOccurred())
				dummyRequest.URL = u

				expectedLightState.StateKnown = true
				expectedLightState.LightOn = true
				expectedReturn, err = json.Marshal(expectedLightState)
				Expect(err).NotTo(HaveOccurred())
			})

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

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

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

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

		Context("When attempting to set state with incorrect state information", func() {
			BeforeEach(func() {
				u, err := url.Parse("/?state=somefakevalue")