Sha256: 6795aab4cf13c0dfd6b5894dabec3474d548ffd414d92b0321b37ef24822b130

Contents?: true

Size: 1.11 KB

Versions: 22

Compression:

Stored size: 1.11 KB

Contents

require "spec_helper"

describe Pliny::Metrics::Backends::Logger do
  let(:io) { double }

  subject(:backend) { Pliny::Metrics::Backends::Logger }

  before do
    @stdout = Pliny.stdout
    Pliny.stdout = io

    allow(io).to receive(:print)
  end

  after do
    Pliny.stdout = @stdout
  end

  context "#count" do
    it "logs a single key with a value" do
      backend.report_counts('app.foo' => 1)
      expect(io).to have_received(:print).with("count#app.foo=1\n")
    end

    it "logs multiple keys with values" do
      backend.report_counts('app.foo' => 1, 'app.bar' => 2)
      expect(io).to have_received(:print).with(
        "count#app.foo=1 count#app.bar=2\n")
    end
  end

  context "#measure" do
    it "logs a single key with a value" do
      backend.report_measures('pliny.foo' => 0.001)
      expect(io).to have_received(:print).with("measure#pliny.foo=0.001\n")
    end

    it "logs multiple keys with values" do
      backend.report_measures('pliny.foo' => 0.3, 'pliny.bar' => 0.5)
      expect(io).to have_received(:print).with(
        "measure#pliny.foo=0.300 measure#pliny.bar=0.500\n")
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pliny-1.1.0 spec/metrics/backends/logger_spec.rb
pliny-1.0.0 spec/metrics/backends/logger_spec.rb
pliny-0.32.0 spec/metrics/backends/logger_spec.rb
pliny-0.31.0 spec/metrics/backends/logger_spec.rb
pliny-0.30.1 spec/metrics/backends/logger_spec.rb
pliny-0.30.0 spec/metrics/backends/logger_spec.rb
pliny-0.29.0 spec/metrics/backends/logger_spec.rb
pliny-0.28.0 spec/metrics/backends/logger_spec.rb
pliny-0.27.1 spec/metrics/backends/logger_spec.rb
pliny-0.27.0 spec/metrics/backends/logger_spec.rb
pliny-0.26.2 spec/metrics/backends/logger_spec.rb
pliny-0.26.1 spec/metrics/backends/logger_spec.rb
pliny-0.26.0 spec/metrics/backends/logger_spec.rb
pliny-0.25.1 spec/metrics/backends/logger_spec.rb
pliny-0.25.0 spec/metrics/backends/logger_spec.rb
pliny-0.24.0 spec/metrics/backends/logger_spec.rb
pliny-0.23.0 spec/metrics/backends/logger_spec.rb
pliny-0.22.0 spec/metrics/backends/logger_spec.rb
pliny-0.21.0 spec/metrics/backends/logger_spec.rb
pliny-0.20.2 spec/metrics/backends/logger_spec.rb