Sha256: 05f4269fc443dc9dc0fa0653ffee365c8135e24d3f9185fe61c562a80904a80b

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 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.3 spec/lib/gom/sensor_port_spec.rb