Sha256: 60e59d244daf0f18f8747191dc31ac1ae70138d90435bab0f6c37e2d4a0d2afc

Contents?: true

Size: 1 KB

Versions: 17

Compression:

Stored size: 1 KB

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" => key,
        "namespaces" => namespaces,
        "value" => 0,
        "type" => "counter"
      }
      expect(subject.to_hash).to match(metric_hash)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
logstash-core-5.0.0.alpha4.snapshot3-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha4.snapshot2-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha4.snapshot1-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot8-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot7-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot6-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot5-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot4-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot2-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha3.snapshot1-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha2-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha2.snapshot2-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha2.snapshot1-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha1-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha1.snapshot2-java spec/logstash/instrument/metric_type/counter_spec.rb
logstash-core-5.0.0.alpha1.snapshot1-java spec/logstash/instrument/metric_type/counter_spec.rb