class

DriverSpecs

Inherits Reference < Object

A place driver has 4 typical points of IO contact

  1. Place driver protocol (placeos-core's point of contact)
  2. The modules transport layer (module to device comms)
  3. An optional HTTP client
  4. Redis for state storage and subscriptions

Constants

DRIVER_ID = "spec_runner"
SYSTEM_ID = "spec_runner_system"

Class methods

mock_driver(driver_name : String, driver_exec = ENV["SPEC_RUN_DRIVER"], &)
Source

Instance methods

errors
Source
example_count
Source
exec(function, *args, user_id = nil)

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"

Source
exec(function, user_id = nil, **args)

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"

Source
exec(function, *args, user_id = nil, &)

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"

Source
exec(function, user_id = nil, **args, &)

executes a function on the driver being tested and returns response promise

i.e. response = exec(:method_on_driver, arg1, arg2)

then to process the response response.get.should eq "method response"

Source
expect_http_request(timeout = 1.seconds, &)

provides a method for accepting and responding to HTTP requests being made by the driver

for an example of how this works see an existing driver

Source
expect_reconnect(timeout = 5.seconds) : TCPSocket

A particular response might disconnect the socket Then we want to wait for the reconnect to occur before continuing the spec

Source
expect_send(timeout = 500.milliseconds) : Bytes

obtain some data you were expecting to receive from the driver. Typically triggered by an exec you've made.

expect_send.should eq "some data"

Source
it(description : String, file = __FILE__, line = __LINE__, **args, &)
Source
publish(channel, message)

publish an event for the driver to process

Source
responds(data)

transmits some data to the driver, typically a response to something the driver has sent

transmit "\nsome response"

Source
settings(new_settings)

allows you to provide alternative settings to the driver being tested.

by default the drivers default_settings are used

Source
should_send(data, timeout = 500.milliseconds)

expects the data provided to be sent

should_send "some data"

Source
status

provides access to the drivers status state.

status[:volume].should eq(50)

Source
system(module_id : String | Symbol)

Grab a Mock driver instance that has been defined by updating the system

For example a system may look like: {Display: {MockDisplay, MockDisplay}}

We can obtain mock display 2 by calling mock_display = system(:Display_2)

Then we can check status on it mock_display[:power]?.should eq true

Source
system(details)

provides a new system definition for testing Logic Modules

expects {ModuleName: {Klass, Klass}}

see an example of it in use

Source
transmit(data, pause = 100.milliseconds)

transmits some data to the driver, typically a response to something the driver has sent

transmit "\nsome response"

Source

Nested types