Sha256: 958cd807bcf700868f57006a744276cecc34e4ebe37546b4ec62290a36503cf7

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

module LIFX
  describe LightCollection do
    subject(:collection) { LightCollection.new(context: double) }

    describe '#with_id' do
      it 'returns a Light with matching id' do
        light = double(Light, id: 'id')
        collection.stub(lights: [light])
        expect(collection.with_id('id')).to eq light
      end

      it 'returns nil when none matches' do
        light = double(Light, id: 'id')
        collection.stub(lights: [light])
        ret = collection.with_id('wrong id')
        expect(ret).to eq nil
      end
    end

    describe '#with_label' do
      it 'returns a Light with matching label' do
        light = double(Light, label: 'label')
        collection.stub(lights: [light])
        expect(collection.with_label('label')).to eq light
      end

      it 'returns nil' do
        light = double(Light, label: 'label')
        collection.stub(lights: [light])
        ret = collection.with_label('wrong label')
        expect(ret).to eq nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lifx-0.4.11 spec/light_collection_spec.rb
lifx-0.4.10 spec/light_collection_spec.rb
lifx-0.4.8 spec/light_collection_spec.rb
lifx-0.4.7 spec/light_collection_spec.rb
lifx-0.4.6.1 spec/light_collection_spec.rb
lifx-0.4.5 spec/light_collection_spec.rb
lifx-0.4.4 spec/light_collection_spec.rb