spec/models/blacklight/solr/search_builder_spec.rb in blacklight-6.0.0.pre1 vs spec/models/blacklight/solr/search_builder_spec.rb in blacklight-6.0.0.pre2
- old
+ new
@@ -1,8 +1,8 @@
require 'spec_helper'
-describe Blacklight::Solr::SearchBuilder do
+describe Blacklight::Solr::SearchBuilderBehavior do
let(:single_facet) { { format: 'Book' } }
let(:multi_facets) { { format: 'Book', language_facet: 'Tibetan' } }
let(:mult_word_query) { 'tibetan history' }
let(:subject_search_params) { { commit: "search", search_field: "subject", action: "index", controller: "catalog", rows: "10", q: "wome" } }
@@ -10,30 +10,35 @@
let(:user_params) { Hash.new }
let(:context) { CatalogController.new }
before { allow(context).to receive(:blacklight_config).and_return(blacklight_config) }
- let(:search_builder) { described_class.new(context) }
+ let(:search_builder_class) do
+ Class.new(Blacklight::SearchBuilder) do
+ include Blacklight::Solr::SearchBuilderBehavior
+ end
+ end
+ let(:search_builder) { search_builder_class.new(context) }
subject { search_builder.with(user_params) }
context "with default processor chain" do
context "with two arguments" do
subject do
Deprecation.silence Blacklight::SearchBuilder do
- described_class.new true, context
+ search_builder_class.new true, context
end
end
it "uses the class-level default_processor_chain" do
- expect(subject.processor_chain).to eq described_class.default_processor_chain
+ expect(subject.processor_chain).to eq search_builder_class.default_processor_chain
end
end
context "with one arguments" do
- subject { described_class.new context }
+ subject { search_builder }
it "uses the class-level default_processor_chain" do
- expect(subject.processor_chain).to eq described_class.default_processor_chain
+ expect(subject.processor_chain).to eq search_builder_class.default_processor_chain
end
end
end
context "with a complex parameter environment" do
@@ -88,10 +93,10 @@
subject do
search_builder.with(user_params).processed_parameters
end
context "when search_params_logic is customized" do
- let(:search_builder) { described_class.new(method_chain, context) }
+ let(:search_builder) { search_builder_class.new(method_chain, context) }
let(:method_chain) { [:add_foo_to_solr_params] }
it "allows customization of search_params_logic" do
allow(search_builder).to receive(:add_foo_to_solr_params) do |solr_params, user_params|
solr_params[:wt] = "TESTING"