bento_search 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_helper.rb CHANGED
@@ -2,14 +2,25 @@
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
4
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
5
6
 
6
- # we insist on minitest, when only the best will do.
7
- # Rails will build on top of it if it's there.
8
- require 'minitest/autorun'
9
- require 'minitest/unit'
10
-
7
+ # we insist on minitest, when only the best will do.
8
+ # Rails will build on top of it if it's there.
9
+ require 'minitest/spec'
11
10
  require "rails/test_help"
12
11
 
12
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
13
+ # to be shown.
14
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
15
+
16
+ # We're not supposed to have to manually install rails-controller-testing, not
17
+ # sure why we do.
18
+ begin
19
+ require 'rails-controller-testing'
20
+ Rails::Controller::Testing.install
21
+ rescue LoadError
22
+ end
23
+
13
24
  Rails.backtrace_cleaner.remove_silencers!
14
25
 
15
26
  # Load support files
@@ -25,23 +36,23 @@ end
25
36
  # back. Useful for efficiency, also useful for
26
37
  # testing code against API's that not everyone
27
38
  # has access to -- the responses can be cached
28
- # and re-used.
39
+ # and re-used.
29
40
  require 'vcr'
30
41
  require 'webmock'
31
42
 
32
43
  # To allow us to do real HTTP requests in a VCR.turned_off, we
33
- # have to tell webmock to let us.
44
+ # have to tell webmock to let us.
34
45
  WebMock.allow_net_connect!
35
46
 
36
47
  VCR.configure do |c|
37
48
  c.cassette_library_dir = 'test/vcr_cassettes'
38
49
  # webmock needed for HTTPClient testing
39
- c.hook_into :webmock
50
+ c.hook_into :webmock
40
51
  end
41
52
 
42
53
  # Silly way to not have to rewrite all our tests if we
43
54
  # temporarily disable VCR, make VCR.use_cassette a no-op
44
- # instead of no-such-method.
55
+ # instead of no-such-method.
45
56
  if ! defined? VCR
46
57
  module VCR
47
58
  def self.use_cassette(*args)
@@ -50,9 +61,9 @@ if ! defined? VCR
50
61
  end
51
62
  end
52
63
 
53
- # re-open to add
64
+ # re-open to add
54
65
  # some custom assertions, that used to be in mini-test, or that
55
- # we wanted to add.
66
+ # we wanted to add.
56
67
  class ActiveSupport::TestCase
57
68
 
58
69
  def assert_present(object, msg = nil)
@@ -65,4 +76,4 @@ class ActiveSupport::TestCase
65
76
  assert object.blank?, msg
66
77
  end
67
78
 
68
- end
79
+ end
@@ -1,49 +1,49 @@
1
1
  require 'test_helper'
2
2
 
3
3
  # Doesn't really test the concurrency, but basic smoke test with fake
4
- # searchers.
4
+ # searchers.
5
5
  class MultiSearcherTest < ActiveSupport::TestCase
6
6
  setup do
7
7
  BentoSearch.register_engine("one") do |conf|
8
- conf.engine = "MockEngine"
8
+ conf.engine = "MockEngine"
9
9
  end
10
10
  BentoSearch.register_engine("two") do |conf|
11
- conf.engine = "MockEngine"
11
+ conf.engine = "MockEngine"
12
12
  end
13
13
  BentoSearch.register_engine("three") do |conf|
14
- conf.engine = "MockEngine"
14
+ conf.engine = "MockEngine"
15
15
  end
16
16
  end
17
-
17
+
18
18
  teardown do
19
19
  BentoSearch.reset_engine_registrations!
20
20
  end
21
-
22
-
21
+
22
+
23
23
  def test_multisearch
24
24
  searcher = BentoSearch::MultiSearcher.new(:one, :two, :three)
25
25
  start_returnval = searcher.start("cancer")
26
-
26
+
27
27
  assert_same searcher, start_returnval
28
-
28
+
29
29
  results = searcher.results
30
-
30
+
31
31
  assert_kind_of Hash, results
32
32
  assert_equal ["one", "two", "three"].sort, results.keys.sort
33
-
33
+
34
34
  ["one", "two", "three"].each do |key|
35
35
  assert_kind_of BentoSearch::Results, results[key]
36
36
  end
37
-
37
+
38
38
  # call results again, we get an empty hash, can only call
39
- # results once per start.
39
+ # results once per start.
40
40
  new_results = searcher.results
41
41
  assert_kind_of Hash, new_results
42
42
  assert_empty new_results
43
-
43
+
44
44
  end
45
-
46
-
47
-
48
-
45
+
46
+
47
+
48
+
49
49
  end
@@ -3,24 +3,24 @@ require 'test_helper'
3
3
  # Test the BentoSearch::Results::Pagination object
4
4
  class PaginationTest < ActiveSupport::TestCase
5
5
  Pagination = BentoSearch::Results::Pagination
6
-
6
+
7
7
  def test_implicit_page
8
8
  pag = Pagination.new(100, {:per_page => 10})
9
-
9
+
10
10
  assert_equal 1, pag.current_page
11
11
  assert_equal 1, pag.start_record
12
12
  assert_equal 10, pag.end_record
13
13
  assert pag.first_page?
14
14
  assert ! pag.last_page?
15
15
  assert_equal 100, pag.count_records
16
- assert_equal 100, pag.total_count # some kaminari's want it called this instead.
16
+ assert_equal 100, pag.total_count # some kaminari's want it called this instead.
17
17
  assert_equal 10, pag.total_pages
18
- assert_equal 10, pag.per_page
18
+ assert_equal 10, pag.per_page
19
19
  end
20
-
20
+
21
21
  def test_last_page
22
22
  pag = Pagination.new(100, {:page => 5, :start => 80, :per_page => 20})
23
-
23
+
24
24
  assert_equal 5, pag.current_page
25
25
  assert_equal 81, pag.start_record
26
26
  assert_equal 80, pag.offset_value
@@ -31,10 +31,10 @@ class PaginationTest < ActiveSupport::TestCase
31
31
  assert_equal 5, pag.total_pages
32
32
  assert_equal 20, pag.per_page
33
33
  end
34
-
34
+
35
35
  def test_uneven_pages
36
36
  pag = Pagination.new(95, {:page => 10, :start => 90, :per_page => 10})
37
-
37
+
38
38
  assert_equal 10, pag.current_page
39
39
  assert_equal 91, pag.start_record
40
40
  assert_equal 95, pag.end_record
@@ -44,10 +44,10 @@ class PaginationTest < ActiveSupport::TestCase
44
44
  assert_equal 10, pag.total_pages
45
45
  assert_equal 10, pag.per_page
46
46
  end
47
-
47
+
48
48
  def test_empty_args
49
49
  pag = Pagination.new(nil, {})
50
-
50
+
51
51
  assert_equal 1, pag.current_page
52
52
  assert_equal 0, pag.start_record
53
53
  assert_equal 0, pag.end_record
@@ -56,6 +56,6 @@ class PaginationTest < ActiveSupport::TestCase
56
56
  assert_equal 0, pag.count_records
57
57
  assert_equal 0, pag.total_pages
58
58
  end
59
-
60
-
59
+
60
+
61
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bento_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.2.3
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5'
22
+ version: '6'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 3.2.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5'
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: confstruct
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -294,6 +294,7 @@ files:
294
294
  - test/dummy/config/initializers/wrap_parameters.rb
295
295
  - test/dummy/config/locales/en.yml
296
296
  - test/dummy/config/routes.rb
297
+ - test/dummy/db/schema.rb
297
298
  - test/dummy/public/404.html
298
299
  - test/dummy/public/422.html
299
300
  - test/dummy/public/500.html
@@ -449,6 +450,7 @@ test_files:
449
450
  - test/dummy/config/locales/en.yml
450
451
  - test/dummy/config/routes.rb
451
452
  - test/dummy/config.ru
453
+ - test/dummy/db/schema.rb
452
454
  - test/dummy/public/404.html
453
455
  - test/dummy/public/422.html
454
456
  - test/dummy/public/500.html