Sha256: 66cfaa904ee1f7445a8af0ecb8ce82f55f1b796beaf61b2324033c460e5edca7

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Influxer::Client do
  after(:each) do
    Rails.cache.clear
  end

  let(:conf) { Influxer.config }
  let(:client) { Influxer.client }

  it "should have config params" do
    expect(client.username).to eq conf.username
    expect(client.port).to eq conf.port
    expect(client.database).to eq conf.database
  end

  describe "cache" do
    before do
      allow_any_instance_of(Influxer::Client).to receive(:query) do |_, sql|
        sql
      end
    end

    let(:q) { "list series" }

    after(:each) do
      conf.cache = false
    end

    it "should write data to cache" do
      conf.cache = {}

      client.cached_query(q)
      expect(Rails.cache.exist?("influxer:listseries")).to be_truthy
    end

    it "should write data to cache with expiration" do
      conf.cache = { expires_in: 1 }

      client.cached_query(q)
      expect(Rails.cache.exist?("influxer:listseries")).to be_truthy

      sleep 2
      expect(Rails.cache.exist?("influxer:listseries")).to be_falsey
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
influxer-0.2.4 spec/client_spec.rb