diff --git a/spec/models/blacklight/configurable_spec.rb b/spec/models/blacklight/configurable_spec.rb index 92e1efdc07..cbdbec582c 100644 --- a/spec/models/blacklight/configurable_spec.rb +++ b/spec/models/blacklight/configurable_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "Blacklight::Configurable" do +RSpec.describe "Blacklight::Configurable", api: true do describe "inheritence" do before(:all) do diff --git a/spec/models/blacklight/configuration/context_spec.rb b/spec/models/blacklight/configuration/context_spec.rb index 5ca24e08f3..384b7c8c24 100644 --- a/spec/models/blacklight/configuration/context_spec.rb +++ b/spec/models/blacklight/configuration/context_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Configuration::Context do +RSpec.describe Blacklight::Configuration::Context, api: true do subject { described_class.new(context) } let(:context) { double } diff --git a/spec/models/blacklight/configuration_spec.rb b/spec/models/blacklight/configuration_spec.rb index 86014bd5ac..1cf704205a 100644 --- a/spec/models/blacklight/configuration_spec.rb +++ b/spec/models/blacklight/configuration_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "Blacklight::Configuration" do +RSpec.describe "Blacklight::Configuration", api: true do let(:config) do Blacklight::Configuration.new diff --git a/spec/models/blacklight/document/active_model_shim_spec.rb b/spec/models/blacklight/document/active_model_shim_spec.rb index e4d28fd5df..931e29b6ac 100644 --- a/spec/models/blacklight/document/active_model_shim_spec.rb +++ b/spec/models/blacklight/document/active_model_shim_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe 'Blacklight::Document::ActiveModelShim' do +RSpec.describe 'Blacklight::Document::ActiveModelShim', api: true do class MockDocument include Blacklight::Document @@ -23,7 +23,7 @@ def documents before do allow(MockDocument).to receive(:repository).and_return(double(find: MockResponse.new([{id: 1}], {}))) end - + describe "#find" do it "should return a document from the repository" do expect(MockDocument.find(1)).to be_a MockDocument diff --git a/spec/models/blacklight/document/cache_key_spec.rb b/spec/models/blacklight/document/cache_key_spec.rb index 6402c07c29..c2dad5e1ef 100644 --- a/spec/models/blacklight/document/cache_key_spec.rb +++ b/spec/models/blacklight/document/cache_key_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Document::CacheKey do +RSpec.describe Blacklight::Document::CacheKey, api: true do let(:attributes) { {} } let(:subject) { SolrDocument.new(attributes) } it 'SolrDocument includes the module' do diff --git a/spec/models/blacklight/document_spec.rb b/spec/models/blacklight/document_spec.rb index ffcef85b55..446fad4e66 100644 --- a/spec/models/blacklight/document_spec.rb +++ b/spec/models/blacklight/document_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Document do +RSpec.describe Blacklight::Document, api: true do let(:data) { {} } subject do Class.new do @@ -14,7 +14,7 @@ data[:x] = true expect(subject).to have_field(:x) end - + it "does not have the field if the field is not in the data" do expect(subject).not_to have_field(:x) end @@ -25,7 +25,7 @@ data[:x] = true expect(subject).to have_field(:x, true) end - + it "does not have the field if the data does not have that value" do data[:x] = false expect(subject).not_to have_field(:x, true) diff --git a/spec/models/blacklight/facet_paginator_spec.rb b/spec/models/blacklight/facet_paginator_spec.rb index be2f189880..752f41156a 100644 --- a/spec/models/blacklight/facet_paginator_spec.rb +++ b/spec/models/blacklight/facet_paginator_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::FacetPaginator do +RSpec.describe Blacklight::FacetPaginator, api: true do let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') } let(:f2) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') } diff --git a/spec/models/blacklight/search_builder_spec.rb b/spec/models/blacklight/search_builder_spec.rb index f14f0314ba..69b4ef9d19 100644 --- a/spec/models/blacklight/search_builder_spec.rb +++ b/spec/models/blacklight/search_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::SearchBuilder do +RSpec.describe Blacklight::SearchBuilder, api: true do let(:processor_chain) { [] } let(:blacklight_config) { Blacklight::Configuration.new } let(:scope) { double blacklight_config: blacklight_config } diff --git a/spec/models/blacklight/solr/document_spec.rb b/spec/models/blacklight/solr/document_spec.rb index e3473575ec..a23e2d1a13 100644 --- a/spec/models/blacklight/solr/document_spec.rb +++ b/spec/models/blacklight/solr/document_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "Blacklight::Solr::Document" do +RSpec.describe "Blacklight::Solr::Document", api: true do class MockDocument include Blacklight::Solr::Document end @@ -33,7 +33,7 @@ def my_extension_method end end - + context "Unique Key" do before(:each) do MockDocument.unique_key = 'my_unique_key' @@ -73,7 +73,7 @@ def my_extension_method #Clear extensions MockDocument.registered_extensions = [] end - + it "should let you register an extension" do MockDocument.use_extension(MockExtension) { |doc| true } @@ -98,19 +98,19 @@ def my_extension_method without_extension = MockDocument.new(:other_key => "value") expect(without_extension.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil - + end it "should not apply an extension whose condition is not met" do MockDocument.use_extension(MockExtension) {|doc| false} doc = MockDocument.new() - - expect(doc.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil + + expect(doc.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil end it "should treat a nil condition as always applyable" do MockDocument.use_extension(MockExtension) - + doc = MockDocument.new() - + expect(doc.methods.find {|name | name.to_s =="my_extension_method"}).not_to be_nil expect(doc.my_extension_method).to eq "my_extension_results" end @@ -118,7 +118,7 @@ def my_extension_method MockDocument.use_extension(MockExtension) MockDocument.use_extension(MockSecondExtension) - expect(MockDocument.new().my_extension_method.to_s).to eq "override" + expect(MockDocument.new().my_extension_method.to_s).to eq "override" end describe "extension_parameters class-level hash" do @@ -126,7 +126,7 @@ def my_extension_method MockDocument.extension_parameters[:key] = "value" expect(MockDocument.extension_parameters[:key]).to eq "value" end - + it "extension_parameters should not be shared between classes" do class_one = Class.new do include Blacklight::Solr::Document @@ -141,7 +141,7 @@ def my_extension_method expect(class_one.extension_parameters[:key]).to eq "class_one_value" end end - + end context "Will export as" do @@ -163,7 +163,7 @@ def export_as_marc it "looks up content-type from Mime::Type if not given in arg" do doc = MockDocument.new doc.will_export_as(:html) - expect(doc.export_formats).to have_key(:html) + expect(doc.export_formats).to have_key(:html) end context "format not registered with Mime::Type" do @@ -171,7 +171,7 @@ def export_as_marc @doc = MockDocument.new @doc.will_export_as(:mock2, "application/mock2" ) # Mime::Type doesn't give us a good way to clean up our new - # registration in an after, sorry. + # registration in an after, sorry. end it "registers format" do expect(defined?("Mime::MOCK2")).to be_truthy @@ -186,7 +186,7 @@ def export_as_marc doc.will_export_as(:marc, "application/marc") expect(doc.export_as(:marc)).to eq "fake_marc" end - + it "should know if a document is exportable" do doc = MockDocument.new doc.will_export_as(:marc, "application/marc") @@ -196,7 +196,7 @@ def export_as_marc context "to_semantic_fields" do class MockDocument - include Blacklight::Solr::Document + include Blacklight::Solr::Document end before do MockDocument.field_semantics.merge!( @@ -205,18 +205,18 @@ class MockDocument something: "something_field" ) - @doc1 = MockDocument.new( + @doc1 = MockDocument.new( "title_field" => "doc1 title", "other_title" => "doc1 title other", "something_field" => ["val1", "val2"], - "not_in_list_field" => "weird stuff" + "not_in_list_field" => "weird stuff" ) end - it "should return complete dictionary based on config'd fields" do + it "should return complete dictionary based on config'd fields" do expect(@doc1.to_semantic_values) .to eq title: ["doc1 title", "doc1 title other"], something: ["val1", "val2"] - end + end it "should return empty array for a key without a value" do expect(@doc1.to_semantic_values[:author]).to be_empty expect(@doc1.to_semantic_values[:nonexistent_token]).to be_empty @@ -225,9 +225,9 @@ class MockDocument expect(@doc1.to_semantic_values[:title]).to be_kind_of(Array) end it "should return complete array for a multi-value field" do - expect(@doc1.to_semantic_values[:something]).to eq ["val1", "val2"] + expect(@doc1.to_semantic_values[:something]).to eq ["val1", "val2"] end - + end context "highlighting" do diff --git a/spec/models/blacklight/solr/facet_paginator_spec.rb b/spec/models/blacklight/solr/facet_paginator_spec.rb index 09f1d6fe61..c53fb52906 100644 --- a/spec/models/blacklight/solr/facet_paginator_spec.rb +++ b/spec/models/blacklight/solr/facet_paginator_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Solr::FacetPaginator do +RSpec.describe Blacklight::Solr::FacetPaginator, api: true do let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') } describe "#as_json" do subject { described_class.new([f1], offset: 0, limit: nil).as_json } diff --git a/spec/models/blacklight/solr/repository_spec.rb b/spec/models/blacklight/solr/repository_spec.rb index 775339ae2e..2ffe6a64ca 100644 --- a/spec/models/blacklight/solr/repository_spec.rb +++ b/spec/models/blacklight/solr/repository_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Solr::Repository do +RSpec.describe Blacklight::Solr::Repository, api: true do let :blacklight_config do CatalogController.blacklight_config.deep_copy @@ -94,12 +94,12 @@ allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc'})).and_return(mock_response) expect(subject.search({qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response end - + it "should preserve the class of the incoming params" do search_params = ActiveSupport::HashWithIndifferentAccess.new search_params[:q] = "query" allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response) - + response = subject.search(search_params) expect(response).to be_a_kind_of Blacklight::Solr::Response expect(response.params).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess diff --git a/spec/models/blacklight/solr/request_spec.rb b/spec/models/blacklight/solr/request_spec.rb index 4d381bce1b..c2d307e1ff 100644 --- a/spec/models/blacklight/solr/request_spec.rb +++ b/spec/models/blacklight/solr/request_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Solr::Request do +RSpec.describe Blacklight::Solr::Request, api: true do before do subject[:qt] = 'hey' subject[:fq] = ["what's up.", "dood"] @@ -15,7 +15,7 @@ subject['spellcheck'] = "a" subject['spellcheck.q'] = "fleece" subject['f.title_facet.facet.limit'] = "vest" - subject['facet.field'] = [] + subject['facet.field'] = [] end it "should accept valid parameters" do expect(subject.to_hash).to eq({"defType" => "had", diff --git a/spec/models/blacklight/solr/response/facets_spec.rb b/spec/models/blacklight/solr/response/facets_spec.rb index 84f7fc4619..702a568905 100644 --- a/spec/models/blacklight/solr/response/facets_spec.rb +++ b/spec/models/blacklight/solr/response/facets_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Solr::Response::Facets do +RSpec.describe Blacklight::Solr::Response::Facets, api: true do describe Blacklight::Solr::Response::Facets::FacetField do describe "A field with default options" do @@ -78,7 +78,7 @@ expect(subject.aggregations['my_field'].sort).to eq 'count' expect(subject.aggregations['my_field'].count?).to eq true end - + it "should default to index if no value is found and the limit is unlimited" do request_params['facet.limit'] = -1 expect(subject.aggregations['my_field'].sort).to eq 'index' @@ -114,7 +114,7 @@ } } end - + subject { Blacklight::Solr::Response.new(response, {}) } it "should mark the facet.missing field with a human-readable label and fq" do @@ -126,7 +126,7 @@ end describe "query facets" do - let(:facet_config) { + let(:facet_config) { double( key: 'my_query_facet_field', :query => { @@ -140,7 +140,7 @@ let(:blacklight_config) { double(facet_fields: { 'my_query_facet_field' => facet_config } )} let(:response) do - { + { facet_counts: { facet_queries: { 'field:search' => 10, @@ -175,18 +175,18 @@ let(:facet_config) { double(key: 'my_pivot_facet_field', query: nil, pivot: ['field_a', 'field_b']) } - + let(:blacklight_config) { double(facet_fields: { 'my_pivot_facet_field' => facet_config } )} let(:response) do - { + { facet_counts: { - facet_pivot: { + facet_pivot: { 'field_a,field_b' => [ { - field: 'field_a', - value: 'a', - count: 10, + field: 'field_a', + value: 'a', + count: 10, pivot: [{field: 'field_b', value: 'b', count: 2}] }] } diff --git a/spec/models/blacklight/solr/response/group_response_spec.rb b/spec/models/blacklight/solr/response/group_response_spec.rb index b9bec4b947..8793ca4dad 100644 --- a/spec/models/blacklight/solr/response/group_response_spec.rb +++ b/spec/models/blacklight/solr/response/group_response_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "spec_helper" -RSpec.describe Blacklight::Solr::Response::GroupResponse do - +RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do + let(:response) do create_response(sample_response) end @@ -29,7 +29,7 @@ end end end - + describe "total" do it "should return the ngroups value" do expect(group.total).to eq 3 @@ -41,7 +41,7 @@ expect(group).to respond_to :aggregations end end - + describe "rows" do it "should get the rows from the response" do expect(group.rows).to eq 3 @@ -59,7 +59,7 @@ expect(group.group_limit).to eq 5 end end - + describe "empty?" do it "uses the total from this object" do expect(group.empty?).to be false @@ -73,8 +73,8 @@ def create_response(response, params = {}) def sample_response {"responseHeader" => {"params" =>{"rows" => 3, "group.limit" => 5}}, - "grouped" => - {'result_group_ssi' => + "grouped" => + {'result_group_ssi' => {'groups' => [{'groupValue'=>"Group 1", 'doclist'=>{'numFound'=>2, 'docs'=>[{:id=>1}]}}, {'groupValue'=>"Group 2", 'doclist'=>{'numFound'=>3, 'docs'=>[{:id=>2}, :id=>3]}} ], diff --git a/spec/models/blacklight/solr/response/group_spec.rb b/spec/models/blacklight/solr/response/group_spec.rb index a1bdb06a4a..6185cb1b7d 100644 --- a/spec/models/blacklight/solr/response/group_spec.rb +++ b/spec/models/blacklight/solr/response/group_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require "spec_helper" -RSpec.describe Blacklight::Solr::Response::Group do - +RSpec.describe Blacklight::Solr::Response::Group, api: true do + let(:response) do create_response(sample_response) end @@ -39,7 +39,7 @@ subject.docs.each do |doc| expect(doc).to be_a_kind_of SolrDocument end - + expect(subject.docs.first.id).to eq 1 end end @@ -59,8 +59,8 @@ def create_response(response, params = {}) def sample_response {"responseHeader" => {"params" =>{"rows" => 3, "group.limit" => 5}}, - "grouped" => - {'result_group_ssi' => + "grouped" => + {'result_group_ssi' => {'groups' => [{'groupValue'=>"Group 1", 'doclist'=>{'numFound'=>2, 'start' => 0, 'docs'=>[{:id=>1}, {:id => 'x'}]}}, {'groupValue'=>"Group 2", 'doclist'=>{'numFound'=>3, 'docs'=>[{:id=>2}, :id=>3]}} ], @@ -68,4 +68,4 @@ def sample_response } } } -end \ No newline at end of file +end diff --git a/spec/models/blacklight/solr/response_spec.rb b/spec/models/blacklight/solr/response_spec.rb index f2357f7bc2..6e126c8175 100644 --- a/spec/models/blacklight/solr/response_spec.rb +++ b/spec/models/blacklight/solr/response_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Solr::Response do +RSpec.describe Blacklight::Solr::Response, api: true do let(:raw_response) { eval(mock_query_response) } let(:config) { Blacklight::Configuration.new } @@ -25,7 +25,7 @@ expect(r).to respond_to(:response) expect(r.docs).to have(11).docs expect(r.params[:echoParams]).to eq 'EXPLICIT' - + expect(r).to be_a(Blacklight::Solr::Response::Facets) end @@ -88,7 +88,7 @@ it "should work like an openstruct" do item = Blacklight::Solr::Response::Facets::FacetItem.new(:value => 'value', :hits => 15) - + expect(item.hits).to eq 15 expect(item.value).to eq 'value' expect(item).to be_a_kind_of(OpenStruct) @@ -204,12 +204,12 @@ allow(r).to receive_messages(:total => 0) expect(r).to be_empty end - + describe "#export_formats" do it "should collect the unique export formats for the current response" do r = Blacklight::Solr::Response.new({}, {}) allow(r).to receive_messages(documents: [double(:export_formats => { a: 1, b: 2}), double(:export_formats => { b: 1, c: 2})]) - expect(r.export_formats).to include :a, :b + expect(r.export_formats).to include :a, :b end end diff --git a/spec/models/blacklight/solr/search_builder_spec.rb b/spec/models/blacklight/solr/search_builder_spec.rb index 7345ee27cc..f0e733ff75 100644 --- a/spec/models/blacklight/solr/search_builder_spec.rb +++ b/spec/models/blacklight/solr/search_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Solr::SearchBuilderBehavior do +RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do let(:single_facet) { { format: 'Book' } } let(:multi_facets) { { format: 'Book', language_ssim: 'Tibetan' } } let(:mult_word_query) { 'tibetan history' } diff --git a/spec/models/blacklight/suggest/response_spec.rb b/spec/models/blacklight/suggest/response_spec.rb index 6deec0c5cd..ec94b2a782 100644 --- a/spec/models/blacklight/suggest/response_spec.rb +++ b/spec/models/blacklight/suggest/response_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::Suggest::Response do +RSpec.describe Blacklight::Suggest::Response, api: true do let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest') } let(:full_response) do described_class.new( @@ -52,4 +52,4 @@ expect(full_response.suggestions.first['term']).to eq 'new jersey' end end -end \ No newline at end of file +end diff --git a/spec/models/blacklight/suggest_search_spec.rb b/spec/models/blacklight/suggest_search_spec.rb index adf663aea5..b9606df73b 100644 --- a/spec/models/blacklight/suggest_search_spec.rb +++ b/spec/models/blacklight/suggest_search_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Blacklight::SuggestSearch do +RSpec.describe Blacklight::SuggestSearch, api: true do let(:params) { {q: 'test'} } let(:response) { instance_double(Blacklight::Suggest::Response)} let(:repository) { instance_double(Blacklight::Solr::Repository, suggestions: response) } diff --git a/spec/models/blacklight/user_spec.rb b/spec/models/blacklight/user_spec.rb index 3f182eb140..145bdf44ba 100644 --- a/spec/models/blacklight/user_spec.rb +++ b/spec/models/blacklight/user_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -RSpec.describe "Blacklight::User" do +RSpec.describe "Blacklight::User", api: true do subject { User.create! :email => 'xyz@example.com', :password => 'xyz12345' } def mock_bookmark document_id Bookmark.new document_id: document_id, document_type: SolrDocument.to_s end - + describe "#bookmarks_for_documents" do before do subject.bookmarks << mock_bookmark(1) subject.bookmarks << mock_bookmark(2) subject.bookmarks << mock_bookmark(3) end - + it "returns all the bookmarks that match the given documents" do bookmarks = subject.bookmarks_for_documents([SolrDocument.new(id: 1), SolrDocument.new(id: 2)]) expect(bookmarks).to have(2).items @@ -22,12 +22,12 @@ def mock_bookmark document_id expect(bookmarks.last.document_id).to eq "2" end end - + describe "#document_is_bookmarked?" do before do subject.bookmarks << mock_bookmark(1) end - + it "is true if the document is bookmarked" do expect(subject).to be_document_is_bookmarked(SolrDocument.new(id: 1)) end @@ -41,10 +41,10 @@ def mock_bookmark document_id before do subject.bookmarks << mock_bookmark(1) end - + it "returns the bookmark for that document id" do expect(subject.existing_bookmark_for(SolrDocument.new(id: 1))).to eq subject.bookmarks.first end end -end +end diff --git a/spec/models/solr_document_spec.rb b/spec/models/solr_document_spec.rb index e33dbd7435..f06a423c92 100644 --- a/spec/models/solr_document_spec.rb +++ b/spec/models/solr_document_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe SolrDocument do +RSpec.describe SolrDocument, api: true do describe "access methods" do let(:solrdoc) do SolrDocument.new(id: '00282214', format: ['Book'], title_tsim: 'some-title') diff --git a/spec/services/blacklight/search_service_spec.rb b/spec/services/blacklight/search_service_spec.rb index 38de58e24a..b91a284501 100644 --- a/spec/services/blacklight/search_service_spec.rb +++ b/spec/services/blacklight/search_service_spec.rb @@ -8,7 +8,7 @@ # to talk with solr and get results)? when we do a document request, does # blacklight code get a single document returned?) # -RSpec.describe Blacklight::SearchService do +RSpec.describe Blacklight::SearchService, api: true do let(:service) { described_class.new(blacklight_config, user_params) } let(:repository) { Blacklight::Solr::Repository.new(blacklight_config) }