Package text search now combines several strategies: exact name match,
name prefix promotion, compound word splitting ("sqlite browser" finds
"sqlitebrowser") and semantic nearest neighbor search over description
embeddings computed by an external embedding service (all-MiniLM-L6-v2,
384 dims) stored with the pgvector extension. Classic PostgreSQL
full-text search remains as fallback when the vector service is
unreachable. Gibberish queries without lexical overlap with the package
data return empty results instead of random matches.
Embeddings can be backfilled with bin/rails debshots:compute_vectors.
Also drops the unused lograge gem from the Gemfile.
44 lines
1.2 KiB
Ruby
44 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
ENV['RAILS_ENV'] ||= 'test'
|
|
require File.expand_path('../config/environment', __dir__)
|
|
require 'rails/test_help'
|
|
|
|
#require 'minitest/reporters'
|
|
#Minitest::Reporters.use!
|
|
|
|
# require "minitest/rails"
|
|
# require "minitest/autorun"
|
|
|
|
# Uncomment for awesome colorful output
|
|
require 'minitest/pride'
|
|
|
|
module ActiveSupport
|
|
class TestCase
|
|
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
fixtures :all
|
|
|
|
# Replace a class-level method with a fixed return value or lambda
|
|
# for the duration of the block. Used to keep tests away from
|
|
# external services like the vector embedding web service.
|
|
def with_stubbed_method(klass, method_name, value_or_lambda)
|
|
original = klass.method(method_name)
|
|
klass.define_singleton_method(method_name) do |*args, **kwargs|
|
|
if value_or_lambda.respond_to?(:call)
|
|
value_or_lambda.call(*args, **kwargs)
|
|
else
|
|
value_or_lambda
|
|
end
|
|
end
|
|
yield
|
|
ensure
|
|
klass.define_singleton_method(method_name, original)
|
|
end
|
|
end
|
|
end
|
|
|
|
module ActionController
|
|
class TestCase
|
|
include Devise::Test::ControllerHelpers
|
|
end
|
|
end
|