diff --git a/spec/caoutsearch/instrumentation/index_spec.rb b/spec/caoutsearch/instrumentation/index_spec.rb new file mode 100644 index 0000000..0fcd0e4 --- /dev/null +++ b/spec/caoutsearch/instrumentation/index_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Caoutsearch::Instrumentation::Index do + before do + Caoutsearch.instrument!(index: true) + + stub_index_class("SampleIndex") + stub_record_class("Sample") + end + + pending "TODO" +end diff --git a/spec/caoutsearch/instrumentation/search_spec.rb b/spec/caoutsearch/instrumentation/search_spec.rb new file mode 100644 index 0000000..56d27ff --- /dev/null +++ b/spec/caoutsearch/instrumentation/search_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Caoutsearch::Instrumentation::Search do + let!(:search) { search_class.new } + let!(:search_class) { stub_search_class("SampleSearch") } + + before do + stub_elasticsearch_search_request("samples", [ + {"_id" => "135", "_source" => {"name" => "Hello World"}}, + {"_id" => "137", "_source" => {"name" => "Hello World"}} + ]) + end + + context "when setting instrumentation to full" do + before { Caoutsearch.instrument!(search: "full") } + + it "saves instrumentation options" do + expect(Caoutsearch.instrumentation_options).to eq({search: "full"}) + end + + it "instruments the search query" do + pending "TODO" + + expect { search.response }.to match_instrumentation + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f32c828..2f83df5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -54,6 +54,11 @@ end end end + + config.after :context, :instrumentation do + Caoutsearch::Instrumentation::Index.detach_from :caoutsearch_index + Caoutsearch::Instrumentation::Search.detach_from :caoutsearch_search + end end def stub_index_class(class_name, &block)