a-lights-spec Pub Share

The implementation of the greeting system

Our system will turn the lights on when a guest arrives:

$when:: home.guest_arrived (name)
   lights.on

Then we have a sensor which we check to see if they're truly on:

$when:: lights.on
   lights.check

We can also mock the systems that we don't have access to yet, let's pretend the lights are bright:

0 $mock:: lights.check
   . (lightIntensity="bright")

Chimes

We also have a chimes system: one that can greet guests. Let's configure it to greet only Jane...

$when:: home.guest_arrived (name is "Jane")
   chimes.welcome (name="Jane"="Jane")

Since we don't have the chimes system built yet, we'll just mock it:

0 $mock:: chimes.welcome
   . (greeting=("Greetings, " + name))

You can see how this new $when rule matches only Jane - so other guests will not be notified... something you can test: so why don't you test to see if John is greeted (hint: change Jane to John in the story and see what happens) !


Was this useful?    

By: Razie | 2016-06-17 .. 2022-05-22 | Tags: spec , dsl , home , private


Viewed 1235 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2024, all rights reserved.