Skip to content

Commit

Permalink
Merge pull request #544 from Casecommons/remove-ostruct-dependency
Browse files Browse the repository at this point in the history
Replace ostruct dependency with RSpec double
  • Loading branch information
nertzy authored Oct 30, 2024
2 parents 1f88614 + e63f32d commit a8f5fdb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions spec/lib/pg_search/features/trigram_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "spec_helper"
require "ostruct"

# standard:disable RSpec/MultipleMemoizedHelpers, RSpec/NestedGroups
describe PgSearch::Features::Trigram do
Expand All @@ -16,7 +15,8 @@
]
}
let(:normalizer) { PgSearch::Normalizer.new(config) }
let(:config) { OpenStruct.new(ignore: []) }
let(:config) { instance_double(PgSearch::Configuration, ignore: ignore) }
let(:ignore) { [] }

let(:coalesced_columns) do
<<~SQL.squish
Expand All @@ -35,7 +35,6 @@

describe "conditions" do
it "escapes the search document and query" do
config.ignore = []
expect(feature.conditions.to_sql).to eq("('#{query}' % (#{coalesced_columns}))")
end

Expand All @@ -45,14 +44,14 @@
end

it 'uses the "<%" operator when searching by word_similarity' do
config.ignore = []
expect(feature.conditions.to_sql).to eq("('#{query}' <% (#{coalesced_columns}))")
end
end

context "when ignoring accents" do
let(:ignore) { [:accents] }

it "escapes the search document and query, but not the accent function" do
config.ignore = [:accents]
expect(feature.conditions.to_sql).to eq("(unaccent('#{query}') % (unaccent(#{coalesced_columns})))")
end
end
Expand Down

0 comments on commit a8f5fdb

Please sign in to comment.