spec/integration/metrics_spec.rb in influxdb-rails-1.0.0.beta3 vs spec/integration/metrics_spec.rb in influxdb-rails-1.0.0.beta4
- old
+ new
@@ -1,28 +1,27 @@
require File.expand_path(File.dirname(__FILE__) + "/integration_helper")
-RSpec.describe WidgetsController, type: :controller do
- render_views
-
+RSpec.describe "User visits widgets", type: :request do
before do
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_environments).and_return(%w[development])
end
describe "in a normal request" do
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
+ expect(InfluxDB::Rails.client).to receive(:write_point).exactly(5).times
+ get "/widgets"
end
- 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
-
+ context "additional values" do
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
+ allow_any_instance_of(ActionDispatch::Request).to receive(:request_id).and_return(:request_id)
+ expect(InfluxDB::Rails.client).to receive(:write_point).with(
+ "rails", a_hash_including(
+ tags: a_hash_including(method: "WidgetsController#index", hook: "process_action"),
+ values: a_hash_including(request_id: :request_id, key: :value)
+ )
+ )
+ get "/widgets"
end
end
end
end