Sha256: e7bcb5944dfba827a231b8baf9d3f7f8f52c5c51b5fa892623cda28df9f19d91

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

Contents

require 'spec_helper'

module LittleBits
  describe CloudBit do
    describe '#output' do
      it 'POSTs an output request to the littleBits Cloud API' do
        stub_request(
            :post,
            'https://api-http.littlebitscloud.cc/devices/DEVICE_ID/output').
            with(
            :body => {
                'duration_ms' => '3000',
                'percent' => '100'
            },
            :headers => {
                'Accept'=>'application/vnd.littlebits.v2+json',
                'Accept-Encoding'=>'gzip, deflate',
                'Authorization'=>'Bearer ACCESS_TOKEN',
                'Content-Length'=>'28',
                'Content-Type'=>'application/x-www-form-urlencoded',
                'User-Agent'=>'Ruby'
            }).
            to_return(:status => 200, :body => 'OK', :headers => {})

        client = LittleBits::CloudBit.new('ACCESS_TOKEN', 'DEVICE_ID')
        result = client.output(100, 3000)

        expect(result).to be_truthy
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
little_bits-0.0.1 spec/lib/cloud_bit_spec.rb