Sha256: facd310cb311137ef94e86bc1cb8a18da2791a2e227d723608f5cec8b03e0775

Contents?: true

Size: 924 Bytes

Versions: 106

Compression:

Stored size: 924 Bytes

Contents

# encoding: utf-8
require "logstash/instrument/metric_type/counter"
require "spec_helper"

describe LogStash::Instrument::MetricType::Counter do
  let(:namespaces) { [:root, :pipelines, :pipeline_01] }
  let(:key) { :mykey }

  subject { LogStash::Instrument::MetricType::Counter.new(namespaces, key) }

  describe "#increment" do
    it "increment the counter" do
      expect{ subject.increment }.to change { subject.value }.by(1)
    end
  end

  describe "#decrement" do
    it "decrement the counter" do
      expect{ subject.decrement }.to change { subject.value }.by(-1)
    end
  end

  context "When serializing to JSON" do
    it "serializes the value" do
      expect(LogStash::Json.dump(subject)).to eq("0")
    end
  end

  context "When creating a hash " do
    it "creates the hash from all the values" do
      metric_hash = { key => 0 }
      expect(subject.to_hash).to match(metric_hash)
    end
  end
end

Version data entries

106 entries across 103 versions & 14 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/logstash-core-5.6.4-java/spec/logstash/instrument/metric_type/counter_spec.rb