Sha256: 693f79be52d8f4b422b23637a1f0425c09ac7594e6a40066029243d0651e12aa

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe XivelyConnector do

  it 'should return correct version string' do
    XivelyConnector.version_string.should == "XivelyConnector version #{XivelyConnector::VERSION::STRING}"
  end

  describe ".connection" do

    it "should be available from the module" do
      XivelyConnector.connect(:api_key=>"abcdefg")
      XivelyConnector.connection.class.should == XivelyConnector::Connection
      XivelyConnector.connection.api_key.should == 'abcdefg'
    end

  end

  describe ".connect" do

    it "should connect using an api-key" do
      XivelyConnector.connect(:api_key=>'abcdefg').api_key.should == 'abcdefg'
      XivelyConnector.connection.class.should == XivelyConnector::Connection
      XivelyConnector.connection.api_key.should == 'abcdefg'
    end

  end

  describe ".disconnect" do

    it "should release the connection" do
      XivelyConnector.connect(:api_key=>"abcdefg")
      XivelyConnector.disconnect
      XivelyConnector.connection.should == nil
    end

  end

  describe ".find" do

    it "should use an existing connection if it exists" do
      XivelyConnector.disconnect
      XivelyConnector.connect(:api_key=>"abcdefg")
      expect {XivelyConnector.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.find('000000001')}.to raise_error
    end

  end


  describe ".find_device_by_id" do

    it "should use an existing connection if it exists" do
      XivelyConnector.disconnect
      XivelyConnector.connect(:api_key=>"abcdefg")
      expect {XivelyConnector.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.find('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/module_spec.rb
xively-rb-connector-0.1.3 spec/xively-rb-connector/module_spec.rb
xively-rb-connector-0.1.2 spec/xively-rb-connector/module_spec.rb