Sha256: b4b86074d9f3460d2d5235a46064aa971514eb55189b5abe243458958bdc68ec
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
require "spec_helper" module Sidewatch describe Cloudwatch do let(:client){ spy("cloudwatch-client") } subject{ described_class.new(client: client) } describe "#send" do it "sends the metrics using the cloudwatch client" do metrics = [] metrics << Metric.new(namespace: "Clocks", name: "Ticks", value: 1234, unit: "Count", dimensions: { "ClockName" => "cuckoo" }, timestamp: Time.at(1440494300)) expected = { namespace: "Clocks", metric_data: [ { metric_name: "Ticks", dimensions: [ { name: "ClockName", value: "cuckoo" } ], timestamp: Time.at(1440494300), value: 1234, unit: "Count" } ] } subject.send(metrics) expect(client).to have_received(:put_metric_data).with(expected) end it "groups the metrics by namespace" do metrics = [] metrics << Metric.new(namespace: "Clocks", name: "Ticks", value: 1234, unit: "Count") metrics << Metric.new(namespace: "Events", name: "Failed", value: 55, unit: "Count") received = [] allow(client).to receive(:put_metric_data){ |data| received << data } subject.send(metrics) expect(received).to contain_exactly(hash_including(namespace: "Clocks"), hash_including(namespace: "Events")) end it "sends metrics in batches of max. 20 entries" do metrics = [] 25.times do |i| metrics << Metric.new(namespace: "Clocks", name: "Ticks", value: i, unit: "Count") end subject.send(metrics) expect(client).to have_received(:put_metric_data).exactly(2).times end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidewatch-0.0.4 | spec/cloudwatch_spec.rb |