Sha256: 35c60c91ff65793b74c7fe1e1c9d361b9d6006f576bfdc3b5bbd152cd60cf328
Contents?: true
Size: 1.71 KB
Versions: 4
Compression:
Stored size: 1.71 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' require 'system_metrics/metric' describe SystemMetrics::Store do include NotificationsSupport describe '#save' do it 'should save an array of events hierarchically' do parent = event(:start => Time.now - 10.seconds, :end => Time.now) child = event(:start => Time.now - 9.seconds, :end => Time.now - 1.seconds) grandchild = event(:start => Time.now - 8.seconds, :end => Time.now - 2.seconds) store = SystemMetrics::Store.new lambda { store.save([grandchild, child, parent]) }.should change(SystemMetrics::Metric, :count).by(3) metrics = SystemMetrics::Metric.all verify_equal(parent, metrics[0]) verify_equal(child, metrics[0].children[0]) verify_equal(grandchild, metrics[0].children[0].children[0]) end it 'should not attempt to save anything if passed an empty array of events' do store = SystemMetrics::Store.new lambda { store.save([]) }.should_not change(SystemMetrics::Metric, :count) end it 'should not attempt to save anything if passed a nil' do store = SystemMetrics::Store.new lambda { store.save(nil) }.should_not change(SystemMetrics::Metric, :count) end end private def verify_equal(event, metric) event.name.should == metric.name event.action.should == metric.action event.category.should == metric.category event.transaction_id.should == metric.transaction_id event.payload.should == metric.payload event.started_at.should be_within(1).of(metric.started_at) event.duration.should be_within(1).of(metric.duration) event.exclusive_duration.should be_within(1).of(metric.exclusive_duration) end end
Version data entries
4 entries across 4 versions & 1 rubygems