mongoid_search 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,9 +8,10 @@ require 'database_cleaner'
8
8
  require 'fast_stemmer'
9
9
  require 'yaml'
10
10
  require 'mongoid_search'
11
+ require 'mongoid-compatibility'
11
12
 
12
13
  Mongoid.configure do |config|
13
- config.connect_to "mongoid_search_test"
14
+ config.connect_to 'mongoid_search_test'
14
15
  end
15
16
 
16
17
  Dir["#{File.dirname(__FILE__)}/models/*.rb"].each { |file| require file }
@@ -19,6 +20,8 @@ DatabaseCleaner.orm = :mongoid
19
20
 
20
21
  RSpec.configure do |config|
21
22
  config.before(:all) do
23
+ Mongoid.logger.level = Logger::INFO
24
+ Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5_or_newer?
22
25
  DatabaseCleaner.strategy = :truncation
23
26
  end
24
27
 
@@ -1,8 +1,7 @@
1
- # encoding: utf-8
1
+
2
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe Mongoid::Search::Util do
5
-
6
5
  before(:all) do
7
6
  @default_proc = Mongoid::Search.stem_proc
8
7
  end
@@ -13,61 +12,61 @@ describe Mongoid::Search::Util do
13
12
 
14
13
  before do
15
14
  Mongoid::Search.stem_keywords = false
16
- Mongoid::Search.ignore_list = ""
15
+ Mongoid::Search.ignore_list = ''
17
16
  Mongoid::Search.stem_proc = @default_proc
18
17
  end
19
18
 
20
- it "should return an empty array if no text is passed" do
21
- expect(Mongoid::Search::Util.normalize_keywords("")).to eq []
19
+ it 'should return an empty array if no text is passed' do
20
+ expect(Mongoid::Search::Util.normalize_keywords('')).to eq []
22
21
  end
23
22
 
24
- it "should return an array of keywords" do
25
- expect(Mongoid::Search::Util.normalize_keywords("keyword").class).to eq Array
23
+ it 'should return an array of keywords' do
24
+ expect(Mongoid::Search::Util.normalize_keywords('keyword').class).to eq Array
26
25
  end
27
26
 
28
- it "should return an array of strings" do
29
- expect(Mongoid::Search::Util.normalize_keywords("keyword").first.class).to eq String
27
+ it 'should return an array of strings' do
28
+ expect(Mongoid::Search::Util.normalize_keywords('keyword').first.class).to eq String
30
29
  end
31
30
 
32
- it "should remove accents from the text passed" do
33
- expect(Mongoid::Search::Util.normalize_keywords("café")).to eq ["cafe"]
31
+ it 'should remove accents from the text passed' do
32
+ expect(Mongoid::Search::Util.normalize_keywords('café')).to eq ['cafe']
34
33
  end
35
34
 
36
- it "should downcase the text passed" do
37
- expect(Mongoid::Search::Util.normalize_keywords("CaFé")).to eq ["cafe"]
35
+ it 'should downcase the text passed' do
36
+ expect(Mongoid::Search::Util.normalize_keywords('CaFé')).to eq ['cafe']
38
37
  end
39
38
 
40
- it "should downcase utf-8 chars of the text passed" do
41
- expect(Mongoid::Search::Util.normalize_keywords("Кафе")).to eq ["кафе"]
39
+ it 'should downcase utf-8 chars of the text passed' do
40
+ expect(Mongoid::Search::Util.normalize_keywords('Кафе')).to eq ['кафе']
42
41
  end
43
42
 
44
- it "should split whitespaces, hifens, dots, underlines, etc.." do
45
- expect(Mongoid::Search::Util.normalize_keywords("CaFé-express.com delicious;come visit, and 'win' an \"iPad\"")).to eq ["cafe", "express", "com", "delicious", "come", "visit", "and", "win", "an", "ipad"]
43
+ it 'should split whitespaces, hifens, dots, underlines, etc..' do
44
+ expect(Mongoid::Search::Util.normalize_keywords("CaFé-express.com delicious;come visit, and 'win' an \"iPad\"")).to eq %w[cafe express com delicious come visit and win an ipad]
46
45
  end
47
46
 
48
- it "should stem keywords" do
47
+ it 'should stem keywords' do
49
48
  Mongoid::Search.stem_keywords = true
50
- expect(Mongoid::Search::Util.normalize_keywords("A runner running and eating")).to eq ["runner", "run", "and", "eat"]
49
+ expect(Mongoid::Search::Util.normalize_keywords('A runner running and eating')).to eq %w[runner run and eat]
51
50
  end
52
51
 
53
- it "should stem keywords using a custom proc" do
52
+ it 'should stem keywords using a custom proc' do
54
53
  Mongoid::Search.stem_keywords = true
55
- Mongoid::Search.stem_proc = lambda { |word| word.upcase }
54
+ Mongoid::Search.stem_proc = ->(word) { word.upcase }
56
55
 
57
- expect(Mongoid::Search::Util.normalize_keywords("A runner running and eating")).to eq ["RUNNER", "RUNNING", "AND", "EATING"]
56
+ expect(Mongoid::Search::Util.normalize_keywords('A runner running and eating')).to eq %w[RUNNER RUNNING AND EATING]
58
57
  end
59
58
 
60
- it "should ignore keywords from ignore list" do
59
+ it 'should ignore keywords from ignore list' do
61
60
  Mongoid::Search.stem_keywords = true
62
- Mongoid::Search.ignore_list = YAML.load(File.open(File.dirname(__FILE__) + '/config/ignorelist.yml'))["ignorelist"]
63
- expect(Mongoid::Search::Util.normalize_keywords("An amazing awesome runner running and eating")).to eq ["an", "runner", "run", "and", "eat"]
61
+ Mongoid::Search.ignore_list = YAML.safe_load(File.open(File.dirname(__FILE__) + '/config/ignorelist.yml'))['ignorelist']
62
+ expect(Mongoid::Search::Util.normalize_keywords('An amazing awesome runner running and eating')).to eq %w[an runner run and eat]
64
63
  end
65
64
 
66
- it "should ignore keywords with less than two words" do
67
- expect(Mongoid::Search::Util.normalize_keywords("A runner running")).not_to include "a"
65
+ it 'should ignore keywords with less than two words' do
66
+ expect(Mongoid::Search::Util.normalize_keywords('A runner running')).not_to include 'a'
68
67
  end
69
68
 
70
- it "should not ignore numbers" do
71
- expect(Mongoid::Search::Util.normalize_keywords("Ford T 1908")).to include "1908"
69
+ it 'should not ignore numbers' do
70
+ expect(Mongoid::Search::Util.normalize_keywords('Ford T 1908')).to include '1908'
72
71
  end
73
72
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Zaffari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fast-stemmer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: mongoid
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,33 +39,33 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: 3.0.0
27
41
  - !ruby/object:Gem::Dependency
28
- name: fast-stemmer
42
+ name: database_cleaner
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 1.0.0
34
- type: :runtime
47
+ version: 0.8.0
48
+ type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 1.0.0
54
+ version: 0.8.0
41
55
  - !ruby/object:Gem::Dependency
42
- name: database_cleaner
56
+ name: mongoid-compatibility
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 0.8.0
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: 0.8.0
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement