Class: StatsD::Instrument::Matchers::Matcher

Inherits:
Object
  • Object
show all
Includes:
RSpec::Matchers::Composable, Helpers
Defined in:
lib/statsd/instrument/matchers.rb

Instance Method Summary collapse

Methods included from Helpers

#capture_statsd_datagrams

Constructor Details

#initialize(metric_type, metric_name, options = {}) ⇒ Matcher

Returns a new instance of Matcher.



20
21
22
23
24
# File 'lib/statsd/instrument/matchers.rb', line 20

def initialize(metric_type, metric_name, options = {})
  @metric_type = metric_type
  @metric_name = metric_name
  @options = options
end

Instance Method Details

#failure_messageObject



33
34
35
# File 'lib/statsd/instrument/matchers.rb', line 33

def failure_message
  @message
end

#failure_message_when_negatedObject



37
38
39
# File 'lib/statsd/instrument/matchers.rb', line 37

def failure_message_when_negated
  "No StatsD calls for metric #{@metric_name} expected."
end

#matches?(block) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/statsd/instrument/matchers.rb', line 26

def matches?(block)
  expect_statsd_call(@metric_type, @metric_name, @options, &block)
rescue RSpec::Expectations::ExpectationNotMetError => e
  @message = e.message
  false
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/statsd/instrument/matchers.rb', line 41

def supports_block_expectations?
  true
end