Sha256: 69ce96c489e69c72352787a97d900d69107613686ff39f5ac22971e64b500a21

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe "Gom::SensorPort" do
  context "given no options" do

    let(:path) { '/gom-sensor-port' }
    let(:station) { Gom::SensorPort.new path }
    let(:json) { <<-JSON
      {
        "node": {
          "uri": "#{path}",
          "entries": [
            { "attribute": {
              "name": "status",
              "node": "#{path}",
              "value": "<void>", "type": "string"
            } }
          ]
        }
      }
      JSON
    }

    before :each do
      ($gom.stub! :read).with("#{path}.json").and_return(json)
    end

    describe "#dispatch_sensor_message" do
      it "writes sensor value to gom" do
        $gom.should_receive(:write).
          with("#{path}:raw", "foo:123")
        $gom.should_receive(:write).
          with("#{path}/values:foo", "123")
        station.dispatch_sensor_message "foo:123"
      end
    end

    describe ".initialize" do
      it "has a default interface" do
        station.interface.should == '0.0.0.0'
      end

      it "defaults to udp mode" do
        station.mode.should == :udp
      end

      it "configures sensor port on 76001" do
        station.port.should == 44470
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gom-sensor-ports-0.2.4 spec/lib/gom/sensor_port_spec.rb