lights-spec Pub

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:

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 == "Jane")
   chimes.welcome (name<-"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 .. 2017-05-01 | Tags: spec , dsl , home


Viewed 125 times ( | Print ) this page.

You need to log in to post a comment!

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