Sha256: 08beb91c1409de128b1c86b6417716c8d16749b808e02669a56e22db65fb1be2

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'
require 'pp'

describe Databox::Client do
  before do
    Databox.configure do |c|
      c.push_token = 'adxg1kq5a4g04k0wk0s4wkssow8osw84'
    end

    allow_any_instance_of(Databox::Client).to receive(:raw_push)\
      .and_return({'status' => 'ok'})
  end

  let!(:client) { Databox::Client.new }

  context 'push' do
    it { expect { client.push(nil) }.to raise_exception }
    it { expect { client.push(key: 'sales.total', value: nil) }.to raise_exception }
    it { expect { client.push(key: nil, value: 3000) }.to raise_exception }
    it { expect(client.push(key: 'sales.total', value: 2000)).to eq true }
  end

  context 'push w/ attributes' do
    it {
      payload = {
          key: 'test',
          value: 200,
          attributes: {
              'me': 'Oto'
          }
      }

      expect(client).to receive(:raw_push)
                            .with('/', [
                                         {"$test" => 200, :me => "Oto"}
                                     ])
                            .once.and_call_original
      expect(client.push(payload)).to eq true
    }
  end

  context 'insert_all' do
    it { expect { client.insert_all([
                                        {key: 'temp.lj'},
                                        {key: 'temp.ljx', value: 60.3},
                                    ]) }.to raise_exception }

    it { expect(client.insert_all([
                                      {key: 'temp.ljx', value: 4.3},
                                      {key: 'temp.ljx', value: 1.3, date: '2015-01-01 09:00:00'},
                                  ])).to eq true }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
databox-0.2.2 spec/databox/client_spec.rb
databox-0.2.1 spec/databox/client_spec.rb