Sha256: 3fb6cf5513ba493b573eb7c2a3e832867c5b0fd5c5bded80cbc88a72cfc3e475

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

RSpec.describe Hue::Light do
  %w{on hue saturation brightness color_temperature alert effect}.each do |attribute|
    before do
      stub_request(:get, "https://www.meethue.com/api/nupnp").
        to_return(:body => '[{"internalipaddress":"localhost"}]')

      stub_request(:get, %r{http://localhost/api/*}).
        to_return(:body => '[{"success":true}]')

      stub_request(:put, %r{http://localhost/api*}).
        to_return(:body => '[{}]')
    end

    describe "##{attribute}=" do
      it "PUTs the new attribute value" do
        client = Hue::Client.new
        light = Hue::Light.new(client, client.bridge, 0, {"state" => {}})

        light.send("#{attribute}=", 24)
        expect(a_request(:put, %r{http://localhost/api/.*/lights/0})).to have_been_made
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hue-0.2.0 spec/hue/light_spec.rb