bento_search 1.7.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -6
- data/app/assets/javascripts/bento_search/ajax_load.js +17 -1
- data/app/controllers/bento_search/search_controller.rb +2 -2
- data/app/models/bento_search/concurrent_searcher.rb +2 -2
- data/app/models/bento_search/result_item.rb +5 -2
- data/app/views/bento_search/_item_title.html.erb +2 -4
- data/lib/bento_search/version.rb +1 -1
- data/lib/generators/bento_search/install/ajax_load_js_generator.rb +15 -0
- data/test/decorator/standard_decorator_test.rb +30 -30
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/config/application.rb +7 -0
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +7 -1
- data/test/dummy/config/environments/test.rb +10 -3
- data/test/functional/bento_search/search_controller_test.rb +5 -1
- data/test/search_engines/google_site_search_test.rb +48 -48
- data/test/search_engines/scopus_engine_test.rb +51 -51
- data/test/support/atom.xsd.xml +3 -3
- data/test/support/xml.xsd +117 -0
- data/test/view/atom_results_test.rb +94 -94
- metadata +27 -49
- data/app/assets/javascripts/bento_search.js +0 -3
- data/app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb +0 -36
- data/app/item_decorators/bento_search/only_premade_openurl.rb +0 -20
- data/app/item_decorators/bento_search/openurl_add_other_link.rb +0 -39
- data/app/item_decorators/bento_search/openurl_main_link.rb +0 -34
- data/app/models/bento_search/multi_searcher.rb +0 -132
- data/test/dummy/config/initializers/secret_token.rb +0 -8
- data/test/dummy/db/schema.rb +0 -15
- data/test/unit/multi_searcher_test.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ed755cb880b6d45bd02d53373d80c25161c6689ef59b7108106896c0a392fc4c
|
4
|
+
data.tar.gz: 4c9009a41299bc44b84274e93c5f0e7a9a5fda599e0de97f6e8972cd3519faf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07e2ba15ccd24b1dc1d1cfac642dd01d60700de90dcd2b63ce164830a4619e30203c728077461123ab39ce7e8da6390d3f5009f6afaba637ebc275f5977fd23e
|
7
|
+
data.tar.gz: 755df58770fa0f91fa9cd0fa8ef507815f762889203f4c63edd9931bd4f15270027a033213fca650334749add1be5d9ef0dc15a64b6b9bf92d75838137db01bc
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# BentoSearch
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![CI Build Status](https://github.com/jrochkind/bento_search/actions/workflows/ruby.yml/badge.svg)](https://github.com/jrochkind/bento_search/actions/workflows/ruby.yml)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/bento_search.png)](http://badge.fury.io/rb/bento_search)
|
5
5
|
|
6
6
|
bento_search provides an abstraction/normalization layer for querying and
|
7
7
|
displaying results from external search engines, in Ruby on Rails. Works with
|
8
|
-
Rails
|
8
|
+
Rails 5.2 - 6.1, ruby 2.5 through 3.0.
|
9
9
|
|
10
10
|
### Goals: To help you
|
11
11
|
|
@@ -283,10 +283,6 @@ the ConcurrentSearcher's concurrency.
|
|
283
283
|
|
284
284
|
For more info, see [BentoSearch::ConcurrentSearcher](./app/models/bento_search/concurrent_searcher.rb).
|
285
285
|
|
286
|
-
The previous **MultiSearcher** class is now deprecated, ConcurrentSearcher
|
287
|
-
is the replacement, and will likely work as a drop-in replacement.
|
288
|
-
See [CHANGES](./CHANGES.md#17) for more info.
|
289
|
-
|
290
286
|
|
291
287
|
|
292
288
|
|
@@ -14,11 +14,26 @@ var BentoSearch = BentoSearch || {}
|
|
14
14
|
// You can set default success_callback function for all calls with:
|
15
15
|
//
|
16
16
|
// BentoSearch.ajax_load.default_success_callback = function(div) { ...
|
17
|
-
|
17
|
+
//
|
18
|
+
// optional beforeSend function.
|
19
|
+
//
|
20
|
+
// beforeSend: to be used by jQuery.ajax as the settings.beforeSend function.
|
21
|
+
// this allows the outgoing request to modified, e.g. to add auth params
|
22
|
+
// in the query param or in a header.
|
23
|
+
// See https://api.jquery.com/jquery.ajax/#jQuery-ajax-settings
|
24
|
+
//
|
25
|
+
// You can set default beforeSend function for all calls with:
|
26
|
+
//
|
27
|
+
// BentoSearch.ajax_load.default_beforeSend = function(xhr, settings) { ...
|
28
|
+
BentoSearch.ajax_load = function(node, success_callback, beforeSend) {
|
18
29
|
// default success_callback
|
19
30
|
if (success_callback === undefined) {
|
20
31
|
success_callback = BentoSearch.ajax_load.default_success_callback;
|
21
32
|
}
|
33
|
+
// default beforeSend
|
34
|
+
if (beforeSend === undefined) {
|
35
|
+
beforeSend = BentoSearch.ajax_load.default_beforeSend;
|
36
|
+
}
|
22
37
|
|
23
38
|
var div = $(node);
|
24
39
|
|
@@ -52,6 +67,7 @@ BentoSearch.ajax_load = function(node, success_callback) {
|
|
52
67
|
div.replaceWith(response);
|
53
68
|
}
|
54
69
|
},
|
70
|
+
beforeSend: beforeSend,
|
55
71
|
error: function(xhr, status, errorThrown) {
|
56
72
|
var msg = "Sorry but there was an error: ";
|
57
73
|
div.html(msg + xhr.status + " " + xhr.statusText + ", " + status);
|
@@ -19,10 +19,10 @@ module BentoSearch
|
|
19
19
|
# in their config will be served by this controller.
|
20
20
|
#
|
21
21
|
# If you need routable results on an engine which ALSO needs to
|
22
|
-
# be protected by auth, you can add your own Rails
|
22
|
+
# be protected by auth, you can add your own Rails before_action
|
23
23
|
# to provide auth. Say, in an initializer in your app:
|
24
24
|
#
|
25
|
-
# SearchController.
|
25
|
+
# SearchController.before_action do |controller|
|
26
26
|
# unless controller.current_user
|
27
27
|
# raise BentoSearch::SearchController::AccessDenied
|
28
28
|
# end
|
@@ -16,7 +16,7 @@ begin
|
|
16
16
|
#
|
17
17
|
# initialize with id's of registered engines:
|
18
18
|
#
|
19
|
-
# searcher = BentoBox::
|
19
|
+
# searcher = BentoBox::ConcurrentSearcher.new(:gbs, :scopus)
|
20
20
|
#
|
21
21
|
# start the concurrent searches, params same as engine.search
|
22
22
|
#
|
@@ -37,7 +37,7 @@ begin
|
|
37
37
|
#
|
38
38
|
# In Rails previous to Rails5, you may have to set config.cache_classes=true
|
39
39
|
# even in development to avoid problems. In Rails 5.x, we take advantage of
|
40
|
-
# new api that should allow concurrency-
|
40
|
+
# new api that should allow concurrency-safe autoloading. But if you run into
|
41
41
|
# any weird problems (such as a deadlock), `cache_classes = true` and
|
42
42
|
# `eager_load = true` should eliminate them, at the cost of dev-mode
|
43
43
|
# auto-reloading.
|
@@ -157,7 +157,7 @@ module BentoSearch
|
|
157
157
|
attr_writer :language_str
|
158
158
|
def language_str
|
159
159
|
(@language_str ||= nil) || language_code.try do |code|
|
160
|
-
LanguageList::LanguageInfo.find(code).try do |lang_obj|
|
160
|
+
LanguageList::LanguageInfo.find(code.dup).try do |lang_obj|
|
161
161
|
lang_obj.name
|
162
162
|
end
|
163
163
|
end
|
@@ -167,7 +167,10 @@ module BentoSearch
|
|
167
167
|
# if available, otherwise from direct language_str if available and
|
168
168
|
# possible.
|
169
169
|
def language_obj
|
170
|
-
@language_obj ||=
|
170
|
+
@language_obj ||= begin
|
171
|
+
lookup = self.language_code || self.language_str
|
172
|
+
LanguageList::LanguageInfo.find( lookup.dup ) if lookup
|
173
|
+
end
|
171
174
|
end
|
172
175
|
|
173
176
|
# Two letter ISO language code, or nil
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# marker will be output after title, in class .bento_available_online
|
18
18
|
#
|
19
19
|
# %>
|
20
|
-
<
|
20
|
+
<h3 class="bento_item_title">
|
21
21
|
<% if local_assigns[:index] %>
|
22
22
|
<% id_attr = item.html_id(local_assigns[:id_prefix], index) %>
|
23
23
|
<%= content_tag("span", :class => "bento_index", :id => (id_attr if id_attr)) do %>
|
@@ -39,6 +39,4 @@
|
|
39
39
|
<% if item.display_configuration.try{|h| h[:indicate_fulltext]} && item.link_is_fulltext? %>
|
40
40
|
<small class="bento_available_online">Online</small>
|
41
41
|
<% end %>
|
42
|
-
</
|
43
|
-
|
44
|
-
|
42
|
+
</h3>
|
data/lib/bento_search/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module BentoSearch
|
3
|
+
module Install
|
4
|
+
class AjaxLoadJsGenerator < ::Rails::Generators::Base
|
5
|
+
source_root BentoSearch::Engine.root.to_s
|
6
|
+
|
7
|
+
desc "Copy ajax_load.js file to local .app/javascript/src/js/"
|
8
|
+
|
9
|
+
def generate
|
10
|
+
copy_file 'app/assets/javascripts/bento_search/ajax_load.js',
|
11
|
+
(Rails.root + "app/javascript/src/js/bento_search_ajax_load.js")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,74 +4,74 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class StandardDecoratorTest < ActionView::TestCase
|
6
6
|
include BentoSearch
|
7
|
-
|
8
|
-
def decorator(hash = {})
|
7
|
+
|
8
|
+
def decorator(hash = {})
|
9
9
|
StandardDecorator.new(
|
10
10
|
ResultItem.new(hash), view
|
11
11
|
)
|
12
12
|
end
|
13
|
-
|
14
|
-
|
13
|
+
|
14
|
+
|
15
15
|
test "author with first and last" do
|
16
16
|
author = Author.new(:last => "Smith", :first => "John")
|
17
|
-
|
17
|
+
|
18
18
|
str = decorator.author_display(author)
|
19
|
-
|
20
|
-
assert_equal "Smith, J", str
|
19
|
+
|
20
|
+
assert_equal "Smith, J", str
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
test "author with display form and just last" do
|
24
24
|
author = Author.new(:last => "Smith", :display => "Display Form")
|
25
|
-
|
25
|
+
|
26
26
|
str = decorator.author_display(author)
|
27
|
-
|
27
|
+
|
28
28
|
assert_equal "Display Form", str
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
test "Author with just last" do
|
32
32
|
author = Author.new(:last => "Johnson")
|
33
|
-
|
33
|
+
|
34
34
|
str = decorator.author_display(author)
|
35
|
-
|
35
|
+
|
36
36
|
assert_equal "Johnson", str
|
37
|
-
|
37
|
+
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
test "Missing title" do
|
41
41
|
assert_equal I18n.translate("bento_search.missing_title"), decorator.complete_title
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
test "language label nil if default" do
|
45
45
|
I18n.with_locale(:'en-GB') do
|
46
|
-
item = decorator(:language_code => 'en')
|
46
|
+
item = decorator(:language_code => 'en')
|
47
47
|
assert_nil item.display_language
|
48
|
-
|
48
|
+
|
49
49
|
item = decorator(:language_code => 'es')
|
50
|
-
assert_equal "Spanish", item.display_language
|
50
|
+
assert_equal "Spanish", item.display_language
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
test "display_language works with just langauge_str" do
|
55
|
-
item = decorator(:language_str => 'German')
|
55
|
+
item = decorator(:language_str => 'German')
|
56
56
|
assert_equal "German", item.display_language
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
test "display_format with nil format" do
|
60
60
|
item = decorator(:format => nil, :format_str => nil)
|
61
|
-
|
61
|
+
|
62
62
|
display_format = item.display_format
|
63
|
-
|
64
|
-
assert_nil display_format
|
63
|
+
|
64
|
+
assert_nil display_format
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
test "display_date" do
|
68
|
-
item = decorator(:year => 1900)
|
68
|
+
item = decorator(:year => 1900)
|
69
69
|
assert_equal "1900", item.display_date
|
70
|
-
|
70
|
+
|
71
71
|
d = Date.new(2010, 5, 5)
|
72
72
|
item = decorator(:publication_date => d)
|
73
73
|
assert_equal I18n.l(d, :format => "%d %b %Y"), item.display_date
|
74
|
-
|
74
|
+
|
75
75
|
# if volume and issue, only prints out year
|
76
76
|
item = decorator(:publication_date => d, :volume => "101", :issue => "2")
|
77
77
|
assert_equal I18n.l(d, :format => "%Y"), item.display_date
|
@@ -112,7 +112,7 @@ class StandardDecoratorTest < ActionView::TestCase
|
|
112
112
|
assert_equal "snippet", item.render_summary, "use snippet if that's all that's there, even when configured for abstract"
|
113
113
|
|
114
114
|
item = decorator()
|
115
|
-
|
115
|
+
assert_nil item.render_summary, "Okay with no snippet or abstract"
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
end
|
@@ -46,6 +46,13 @@ module Dummy
|
|
46
46
|
|
47
47
|
# Version of your assets, change this if you want to expire all your assets
|
48
48
|
config.assets.version = '1.0'
|
49
|
+
|
50
|
+
# Avoid Rails deprecation warning
|
51
|
+
if Gem::Version.new(Rails.version).release >= Gem::Version.new("5.2.0") && Gem::Version.new(Rails.version).release < Gem::Version.new("6.0.0")
|
52
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true
|
53
|
+
end
|
54
|
+
|
55
|
+
config.secret_key_base = '60f73d25f61301b1ea3119011efb9fd9a741fcc010757599341d45765fbda7676daf5d602fb17bb5085c3163a04e20c0750ad02562ee9cb7f03f813d1b62c639'
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
@@ -9,7 +9,11 @@ Dummy::Application.configure do
|
|
9
9
|
config.action_controller.perform_caching = true
|
10
10
|
|
11
11
|
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
-
|
12
|
+
if Rails::VERSION::MAJOR < 5
|
13
|
+
config.serve_static_files = false
|
14
|
+
else
|
15
|
+
config.public_file_server.enabled = false
|
16
|
+
end
|
13
17
|
|
14
18
|
# Compress JavaScripts and CSS
|
15
19
|
config.assets.compress = true
|
@@ -60,4 +64,6 @@ Dummy::Application.configure do
|
|
60
64
|
|
61
65
|
# Send deprecation notices to registered listeners
|
62
66
|
config.active_support.deprecation = :notify
|
67
|
+
|
68
|
+
config.eager_load = true
|
63
69
|
end
|
@@ -8,11 +8,16 @@ Dummy::Application.configure do
|
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
|
12
|
-
|
11
|
+
if Rails::VERSION::MAJOR < 5
|
12
|
+
config.serve_static_files = true
|
13
|
+
config.static_cache_control = "public, max-age=3600"
|
14
|
+
else
|
15
|
+
config.public_file_server.enabled = true
|
16
|
+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
17
|
+
end
|
13
18
|
|
14
19
|
config.eager_load = false
|
15
|
-
|
20
|
+
|
16
21
|
# Show full error reports and disable caching
|
17
22
|
config.consider_all_requests_local = true
|
18
23
|
config.action_controller.perform_caching = false
|
@@ -32,4 +37,6 @@ Dummy::Application.configure do
|
|
32
37
|
config.active_support.deprecation = :stderr
|
33
38
|
|
34
39
|
config.active_support.test_order = :random
|
40
|
+
|
41
|
+
config.eager_load = false
|
35
42
|
end
|
@@ -114,7 +114,11 @@ module BentoSearch
|
|
114
114
|
# SUPER HACKY, but I dunno what else to do.
|
115
115
|
|
116
116
|
class CustomSearchController < BentoSearch::SearchController
|
117
|
-
|
117
|
+
if respond_to?(:before_action)
|
118
|
+
before_action :deny_everyone
|
119
|
+
else
|
120
|
+
before_filter :deny_everyone
|
121
|
+
end
|
118
122
|
|
119
123
|
def deny_everyone
|
120
124
|
raise BentoSearch::SearchController::AccessDenied
|
@@ -7,123 +7,123 @@ require 'cgi'
|
|
7
7
|
# ENV GOOGLE_SITE_SEARCH_KEY and GOOGLE_SITE_SEARCH_CX
|
8
8
|
class GoogleSiteSearchTest < ActiveSupport::TestCase
|
9
9
|
extend TestWithCassette
|
10
|
-
|
10
|
+
|
11
11
|
@@api_key = ENV["GOOGLE_SITE_SEARCH_KEY"] || "DUMMY_API_KEY"
|
12
12
|
@@cx = ENV["GOOGLE_SITE_SEARCH_CX"] || "DUMMY_CX"
|
13
|
-
|
13
|
+
|
14
14
|
VCR.configure do |c|
|
15
15
|
c.filter_sensitive_data("DUMMY_API_KEY", :google_site) { @@api_key }
|
16
16
|
c.filter_sensitive_data("DUMMY_CX", :google_site) { @@cx }
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
setup do
|
20
20
|
@config = {:api_key => @@api_key, :cx => @@cx}
|
21
21
|
@engine = BentoSearch::GoogleSiteSearchEngine.new(@config)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
test("basic query construction") do
|
25
25
|
url = @engine.send(:construct_query, {:query => "hours policies"})
|
26
|
-
|
27
|
-
query_params = CGI.parse( URI.parse(url).query )
|
26
|
+
|
27
|
+
query_params = CGI.parse( URI.parse(url).query )
|
28
28
|
|
29
29
|
assert_equal ["hours policies"], query_params["q"]
|
30
30
|
end
|
31
|
-
|
32
|
-
test("pagination construction") do
|
31
|
+
|
32
|
+
test("pagination construction") do
|
33
33
|
url = @engine.send(:construct_query, {:query => "books", :per_page => 5, :start => 10})
|
34
|
-
|
34
|
+
|
35
35
|
query_params = CGI.parse( URI.parse(url).query )
|
36
|
-
|
36
|
+
|
37
37
|
assert_equal ["5"], query_params["num"]
|
38
38
|
assert_equal ["11"], query_params["start"]
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
test("silently refuses to paginate too far") do
|
42
42
|
# google won't let you paginate past ~10 pages, (101 - num). We silently
|
43
43
|
# refuse
|
44
|
-
|
44
|
+
|
45
45
|
url = @engine.send(:construct_query, {:query => "books", :start => 110})
|
46
|
-
|
46
|
+
|
47
47
|
query_params = CGI.parse( URI.parse(url).query )
|
48
|
-
|
48
|
+
|
49
49
|
assert_equal ["91"], query_params["start"]
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
test_with_cassette("pagination object is correct for actual page when you ask for too far", :google_site) do
|
53
53
|
results = @engine.search("books", :start => 1000)
|
54
|
-
|
54
|
+
|
55
55
|
pagination = results.pagination
|
56
|
-
|
56
|
+
|
57
57
|
assert_equal 10, pagination.current_page
|
58
|
-
assert_equal 91, pagination.start_record
|
58
|
+
assert_equal 91, pagination.start_record
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
test("sort query construction") do
|
62
62
|
url = @engine.send(:construct_query, {:query => "books", :sort => "date_desc"})
|
63
|
-
|
63
|
+
|
64
64
|
query_params = CGI.parse( URI.parse(url).query )
|
65
|
-
|
65
|
+
|
66
66
|
assert_equal ["date"], query_params["sort"]
|
67
67
|
end
|
68
|
-
|
69
|
-
test_with_cassette("basic smoke test", :google_site) do
|
68
|
+
|
69
|
+
test_with_cassette("basic smoke test", :google_site) do
|
70
70
|
results = @engine.search("books")
|
71
|
-
|
71
|
+
|
72
72
|
assert_present results
|
73
73
|
assert_present results.total_items
|
74
|
-
assert_kind_of
|
75
|
-
|
74
|
+
assert_kind_of 1.class, results.total_items
|
75
|
+
|
76
76
|
first = results.first
|
77
|
-
|
77
|
+
|
78
78
|
assert_present first.title
|
79
79
|
assert_present first.link
|
80
80
|
assert_present first.abstract
|
81
|
-
assert_present first.journal_title # used as source_title for display url
|
82
|
-
|
81
|
+
assert_present first.journal_title # used as source_title for display url
|
82
|
+
|
83
83
|
# no openurls for google, we decided
|
84
84
|
assert_nil BentoSearch::StandardDecorator.new(first, nil).to_openurl
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
test_with_cassette("with highlighting", :google_site) do
|
88
88
|
engine = BentoSearch::GoogleSiteSearchEngine.new(@config.merge(:highlighting => true))
|
89
|
-
|
89
|
+
|
90
90
|
results = engine.search("books")
|
91
|
-
|
91
|
+
|
92
92
|
first = results.first
|
93
93
|
|
94
|
-
assert first.title.html_safe?
|
94
|
+
assert first.title.html_safe?
|
95
95
|
assert first.abstract.html_safe?
|
96
|
-
assert first.journal_title.html_safe?
|
96
|
+
assert first.journal_title.html_safe?
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
test_with_cassette("without highlighting", :google_site) do
|
100
100
|
engine = BentoSearch::GoogleSiteSearchEngine.new(@config.merge(:highlighting => false))
|
101
|
-
|
101
|
+
|
102
102
|
results = engine.search("books")
|
103
|
-
|
103
|
+
|
104
104
|
first = results.first
|
105
|
-
|
106
|
-
assert ! first.title.html_safe?
|
105
|
+
|
106
|
+
assert ! first.title.html_safe?
|
107
107
|
assert ! first.abstract.html_safe?
|
108
|
-
assert ! first.journal_title.html_safe?
|
108
|
+
assert ! first.journal_title.html_safe?
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
test_with_cassette("empty result set", :google_site) do
|
112
112
|
results = nil
|
113
113
|
assert_nothing_raised { results = @engine.search('"adfa lakjdr xavier aldkfj 92323kjadf"') }
|
114
|
-
|
114
|
+
|
115
115
|
assert ! results.failed?
|
116
|
-
|
117
|
-
assert results.empty?
|
116
|
+
|
117
|
+
assert results.empty?
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
test_with_cassette("gets format string", :google_site) do
|
121
121
|
results = @engine.search("PDF")
|
122
122
|
|
123
123
|
# assume at least one result had a PDF format, which it does
|
124
124
|
# in our current VCR capture. For a new one, find a search where
|
125
|
-
# it does.
|
126
|
-
assert_present(results.find_all {|i| i.format_str =~ /PDF/ }, "At least one result has PDF in format_str")
|
125
|
+
# it does.
|
126
|
+
assert_present(results.find_all {|i| i.format_str =~ /PDF/ }, "At least one result has PDF in format_str")
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
end
|