spec/integration/metrics_spec.rb in influxdb-rails-1.0.0.beta1 vs spec/integration/metrics_spec.rb in influxdb-rails-1.0.0.beta2

- old
+ new

@@ -1,21 +1,28 @@ require File.expand_path(File.dirname(__FILE__) + "/integration_helper") -RSpec.describe "collecting metrics through ActiveSupport::Notifications", type: :request do +RSpec.describe WidgetsController, type: :controller do + render_views + before do - InfluxDB::Rails.configure do |config| - config.ignored_environments = %w[development] - end + allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_environments).and_return(%w[development]) end describe "in a normal request" do - it "should attempt to handle ActionController metrics" do - expect(InfluxDB::Rails).to receive(:handle_action_controller_metrics).once - get "/widgets" + it "should result in attempts to write metrics via the client" do + expect(InfluxDB::Rails.client).to receive(:write_point).exactly(6).times + get :index end - it "should result in attempts to write metrics via the client" do - expect(InfluxDB::Rails.client).to receive(:write_point).exactly(3).times - get "/widgets" + context "with sql reports enabled" do + before do + allow_any_instance_of(InfluxDB::Rails::Middleware::SqlSubscriber).to receive(:series_name).and_return("rails.sql") + get :index # to not count ActiveRecord initialization + end + + it "should result in attempts to write metrics via the client" do + expect(InfluxDB::Rails.client).to receive(:write_point).exactly(7).times + get :index + end end end end