Sha256: 4a81e8d752bcfbccebcf2cce90e3ede8df514fbe460810a6b688c4c17ea14f09

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'spec_helper'

module CloudBit
  describe Client 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 = CloudBit::Client.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
cloud_bit-0.0.1 spec/lib/cloud_bit/client_spec.rb