Sha256: 0665f5909bdf215a075a09064212a4c920f1299c2d6501033d86d00a1e4ddd10

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe XivelyConnector::Device do

  describe ".find" do

    it "should use an existing connection if it exists" do
      XivelyConnector.disconnect
      XivelyConnector.connect(:api_key=>"abcdefg")
      expect {XivelyConnector::Device.find('000000001')}.not_to raise_error
    end

    it "should raise an error if a connection doesn't exists and no api_key is provided" do
      XivelyConnector.disconnect
      expect {XivelyConnector::Device.find('000000001')}.to raise_error
    end

    it "should return a device object" do
      d = XivelyConnector::Device.find('000000001', "abcdefg")
      d.title.should == 'Smart Meter'
    end

  end

  describe ".find_by_id" do

    it "should use an existing connection if it exists" do
      XivelyConnector.disconnect
      XivelyConnector.connect(:api_key=>"abcdefg")
      expect {XivelyConnector::Device.find_by_id('000000001')}.not_to raise_error
    end

    it "should raise an error if a connection doesn't exists and no api_key is provided" do
      XivelyConnector.disconnect
      expect {XivelyConnector::Device.find_by_id('000000001')}.to raise_error
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xively-rb-connector-0.1.4 spec/xively-rb-connector/device_spec.rb
xively-rb-connector-0.1.3 spec/xively-rb-connector/device_spec.rb
xively-rb-connector-0.1.2 spec/xively-rb-connector/device_spec.rb