module InfluxDB::Rails::Matchers

Public Instance Methods

expect_metric(name: "rails", **options) click to toggle source
# File lib/influxdb/rails/helpers/rspec_matchers.rb, line 7
def expect_metric(name: "rails", **options)
  expect(metrics).to include(
    a_hash_including(options.merge(name: name))
  )
end
expect_no_metric(name: "rails", **options) click to toggle source
# File lib/influxdb/rails/helpers/rspec_matchers.rb, line 13
def expect_no_metric(name: "rails", **options)
  expect(metrics).not_to include(
    a_hash_including(options.merge(name: name))
  )
end
metrics() click to toggle source
# File lib/influxdb/rails/helpers/rspec_matchers.rb, line 28
def metrics
  TestClient.metrics
end
save_and_open_metrics() click to toggle source
# File lib/influxdb/rails/helpers/rspec_matchers.rb, line 19
def save_and_open_metrics
  dir = File.join(File.dirname(__FILE__), "..", "..", "tmp")
  FileUtils.mkdir_p(dir)
  file_path = File.join(dir, "metrics.json")
  output = JSON.pretty_generate(metrics)
  File.write(file_path, output, mode: "wb")
  ::Launchy.open(file_path)
end