Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
inkstak committed Aug 27, 2024
1 parent 8846821 commit e67a6db
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/caoutsearch/instrumentation/index_spec.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions spec/caoutsearch/instrumentation/search_spec.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e67a6db

Please sign in to comment.