Skip to content
Browse files

Merge pull request #7 from lukemelia/gauge-value

Allow a gauge's value to be specified in the event payload
  • Loading branch information...
2 parents 9975d64 + 45cab45 commit 010b688cdd031b58aab27ecdb7b21a0ae866c4f8 Adam Hawkins committed
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/harness/gauge.rb
  2. +10 −0 test/unit/gauge_test.rb
View
2 lib/harness/gauge.rb
@@ -15,7 +15,7 @@ def self.from_event(event)
end
gauge.id ||= event.name
- gauge.value = event.duration
+ gauge.value ||= event.duration
gauge
end
View
10 test/unit/gauge_test.rb
@@ -65,6 +65,16 @@ def test_sets_id_from_payload_if_string
assert_equal 'foo', gauge.id
end
+ def test_sets_value_from_payload_if_number
+ base = Time.now
+
+ event = ActiveSupport::Notifications::Event.new "name", base - 1, Time.now, nil, :gauge => {value: 42}
+
+ gauge = Harness::Gauge.from_event event
+
+ assert_equal 42, gauge.value
+ end
+
def test_initializes_time_if_not_set
gauge = Harness::Gauge.new

0 comments on commit 010b688

Please sign in to comment.
Something went wrong with that request. Please try again.