trailblazer-finder 0.1.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml +101 -0
  4. data/.rubocop.yml +3 -43
  5. data/.rubocop_todo.yml +42 -196
  6. data/.travis.yml +5 -8
  7. data/Gemfile +2 -2
  8. data/LICENSE.txt +7 -21
  9. data/README.md +177 -292
  10. data/Rakefile +12 -12
  11. data/lib/trailblazer/finder.rb +48 -23
  12. data/lib/trailblazer/finder/activity/find.rb +57 -0
  13. data/lib/trailblazer/finder/activity/prepare.rb +29 -0
  14. data/lib/trailblazer/finder/activity/prepare/adapters.rb +66 -0
  15. data/lib/trailblazer/finder/activity/prepare/entity.rb +32 -0
  16. data/lib/trailblazer/finder/activity/prepare/filters.rb +36 -0
  17. data/lib/trailblazer/finder/activity/prepare/paging.rb +49 -0
  18. data/lib/trailblazer/finder/activity/prepare/params.rb +33 -0
  19. data/lib/trailblazer/finder/activity/prepare/properties.rb +47 -0
  20. data/lib/trailblazer/finder/activity/prepare/sorting.rb +57 -0
  21. data/lib/trailblazer/finder/activity/process.rb +18 -0
  22. data/lib/trailblazer/finder/activity/process/adapters.rb +48 -0
  23. data/lib/trailblazer/finder/activity/process/filters.rb +28 -0
  24. data/lib/trailblazer/finder/activity/process/paging.rb +26 -0
  25. data/lib/trailblazer/finder/activity/process/predicates.rb +30 -0
  26. data/lib/trailblazer/finder/activity/process/sorting.rb +26 -0
  27. data/lib/trailblazer/finder/adapters/active_record/paging.rb +9 -8
  28. data/lib/trailblazer/finder/adapters/active_record/predicates.rb +78 -17
  29. data/lib/trailblazer/finder/adapters/active_record/sorting.rb +14 -12
  30. data/lib/trailblazer/finder/adapters/basic/paging.rb +21 -0
  31. data/lib/trailblazer/finder/adapters/basic/predicates.rb +115 -0
  32. data/lib/trailblazer/finder/adapters/basic/sorting.rb +40 -0
  33. data/lib/trailblazer/finder/adapters/kaminari/paging.rb +21 -0
  34. data/lib/trailblazer/finder/adapters/sequel/paging.rb +9 -8
  35. data/lib/trailblazer/finder/adapters/sequel/predicates.rb +78 -17
  36. data/lib/trailblazer/finder/adapters/sequel/sorting.rb +17 -15
  37. data/lib/trailblazer/finder/adapters/will_paginate/paging.rb +21 -0
  38. data/lib/trailblazer/finder/base.rb +20 -83
  39. data/lib/trailblazer/finder/dsl.rb +56 -0
  40. data/lib/trailblazer/finder/find.rb +28 -15
  41. data/lib/trailblazer/finder/helpers/basic.rb +44 -0
  42. data/lib/trailblazer/finder/helpers/sorting.rb +54 -0
  43. data/lib/trailblazer/finder/utils/array.rb +20 -0
  44. data/lib/trailblazer/finder/utils/extra.rb +10 -20
  45. data/lib/trailblazer/finder/utils/hash.rb +36 -0
  46. data/lib/trailblazer/finder/utils/splitter.rb +16 -17
  47. data/lib/trailblazer/finder/utils/string.rb +20 -10
  48. data/lib/trailblazer/finder/version.rb +3 -1
  49. data/lib/trailblazer/operation/finder.rb +20 -19
  50. data/spec/spec_helper.rb +5 -11
  51. data/spec/spec_helper_active_record.rb +11 -12
  52. data/spec/spec_helper_sequel.rb +4 -4
  53. data/spec/spec_helper_will_paginate.rb +13 -0
  54. data/spec/trailblazer/finder/adapters/active_record_spec.rb +267 -0
  55. data/spec/trailblazer/finder/adapters/basic_spec.rb +251 -0
  56. data/spec/trailblazer/finder/adapters/kaminari_spec.rb +78 -32
  57. data/spec/trailblazer/finder/adapters/sequel_spec.rb +267 -0
  58. data/spec/trailblazer/finder/adapters/will_paginate_spec.rb +81 -40
  59. data/spec/trailblazer/finder/base_spec.rb +292 -204
  60. data/spec/trailblazer/finder/dsl_spec.rb +213 -0
  61. data/spec/trailblazer/finder/utils/hash_spec.rb +26 -0
  62. data/spec/trailblazer/finder/utils/splitter_spec.rb +39 -0
  63. data/spec/trailblazer/finder/utils/string_spec.rb +52 -9
  64. data/spec/trailblazer/operation/finder_spec.rb +35 -32
  65. data/trailblazer-finder.gemspec +31 -30
  66. metadata +119 -137
  67. data/lib/trailblazer/finder/adapters.rb +0 -26
  68. data/lib/trailblazer/finder/adapters/active_record.rb +0 -32
  69. data/lib/trailblazer/finder/adapters/data_mapper.rb +0 -32
  70. data/lib/trailblazer/finder/adapters/data_mapper/paging.rb +0 -20
  71. data/lib/trailblazer/finder/adapters/data_mapper/predicates.rb +0 -42
  72. data/lib/trailblazer/finder/adapters/data_mapper/sorting.rb +0 -38
  73. data/lib/trailblazer/finder/adapters/friendly_id.rb +0 -31
  74. data/lib/trailblazer/finder/adapters/kaminari.rb +0 -18
  75. data/lib/trailblazer/finder/adapters/sequel.rb +0 -32
  76. data/lib/trailblazer/finder/adapters/will_paginate.rb +0 -18
  77. data/lib/trailblazer/finder/errors/block_ignored.rb +0 -11
  78. data/lib/trailblazer/finder/errors/invalid_defined_by_value.rb +0 -11
  79. data/lib/trailblazer/finder/errors/invalid_number.rb +0 -16
  80. data/lib/trailblazer/finder/errors/missing_entity_type.rb +0 -11
  81. data/lib/trailblazer/finder/errors/with_ignored.rb +0 -11
  82. data/lib/trailblazer/finder/features.rb +0 -23
  83. data/lib/trailblazer/finder/features/paging.rb +0 -55
  84. data/lib/trailblazer/finder/features/predicate.rb +0 -32
  85. data/lib/trailblazer/finder/features/sorting.rb +0 -108
  86. data/lib/trailblazer/finder/filter.rb +0 -66
  87. data/lib/trailblazer/finder/predicates.rb +0 -39
  88. data/lib/trailblazer/finder/utils/deep_locate.rb +0 -30
  89. data/lib/trailblazer/finder/utils/params.rb +0 -28
  90. data/lib/trailblazer/finder/utils/parse.rb +0 -25
  91. data/spec/spec_helper_data_mapper.rb +0 -35
  92. data/spec/support/paging_shared_example.rb +0 -65
  93. data/spec/support/sorting_shared_example.rb +0 -125
  94. data/spec/trailblazer/finder/adapters/active_record/base_spec.rb +0 -112
  95. data/spec/trailblazer/finder/adapters/active_record/paging_spec.rb +0 -64
  96. data/spec/trailblazer/finder/adapters/active_record/predicates_spec.rb +0 -101
  97. data/spec/trailblazer/finder/adapters/active_record/sorting_spec.rb +0 -99
  98. data/spec/trailblazer/finder/adapters/data_mapper/base_spec.rb +0 -112
  99. data/spec/trailblazer/finder/adapters/data_mapper/paging_spec.rb +0 -64
  100. data/spec/trailblazer/finder/adapters/data_mapper/predicates_spec.rb +0 -100
  101. data/spec/trailblazer/finder/adapters/data_mapper/sorting_spec.rb +0 -97
  102. data/spec/trailblazer/finder/adapters/friendly_id_spec.rb +0 -46
  103. data/spec/trailblazer/finder/adapters/sequel/base_spec.rb +0 -125
  104. data/spec/trailblazer/finder/adapters/sequel/paging_spec.rb +0 -64
  105. data/spec/trailblazer/finder/adapters/sequel/predicates_spec.rb +0 -89
  106. data/spec/trailblazer/finder/adapters/sequel/sorting_spec.rb +0 -110
  107. data/spec/trailblazer/finder/adapters_spec.rb +0 -110
  108. data/spec/trailblazer/finder/features/paging_spec.rb +0 -104
  109. data/spec/trailblazer/finder/features/predicates_spec.rb +0 -99
  110. data/spec/trailblazer/finder/features/sorting_spec.rb +0 -96
  111. data/spec/trailblazer/finder/features_spec.rb +0 -55
  112. data/spec/trailblazer/finder/filter_spec.rb +0 -133
  113. data/spec/trailblazer/finder/find_spec.rb +0 -72
  114. data/spec/trailblazer/finder/utils/extra_spec.rb +0 -41
  115. data/spec/trailblazer/finder/utils/params_spec.rb +0 -39
  116. data/spec/trailblazer/finder/utils/parse_spec.rb +0 -33
  117. data/spec/trailblazer/operation/paging_spec.rb +0 -68
  118. data/spec/trailblazer/operation/predicates_spec.rb +0 -127
  119. data/spec/trailblazer/operation/sorting_spec.rb +0 -80
  120. data/spec/trailblazer/test_spec.rb +0 -41
@@ -1,96 +0,0 @@
1
- # require 'spec_helper_sequel'
2
- require 'spec_helper'
3
-
4
- module Trailblazer
5
- class Finder
6
- module Features
7
- describe Sorting, :sorting do
8
- class TestSortingFinder < Trailblazer::Finder
9
- features Sorting
10
-
11
- def create_product(id, name, price)
12
- {
13
- id: id,
14
- name: name,
15
- price: price,
16
- created_at: Time.now,
17
- updated_at: Time.now
18
- }
19
- end
20
-
21
- entity_type do
22
- Array.new(5) do |i|
23
- next create_product(i + 1, '', "1#{i}".to_i) if i == 7
24
- next create_product(i + 1, 'Name4', "1#{i}".to_i) if i == 9
25
- create_product(i + 1, "Name#{i}", "1#{i}".to_i)
26
- end.push(create_product(6, 'Name3', 8))
27
- end
28
-
29
- sortable_by :name, :price, :created_at, :id
30
-
31
- filter_by :name
32
- filter_by :price
33
- filter_by(:category) { |entity_type, _| entity_type.joins(:category) }
34
- end
35
-
36
- def finder_with_sort(sort = nil, filters = {})
37
- TestSortingFinder.new filter: (sort.nil? ? {} : { sort: sort }).merge(filters)
38
- end
39
-
40
- def finder_with_nil_sort
41
- TestSortingFinder.new filter: { sort: nil }
42
- end
43
-
44
- describe 'sorting' do
45
- it 'loads results if no sort options are supplied in the params' do
46
- finder = finder_with_nil_sort
47
- expect(finder.results.map { |n| n[:price] }).to eq [14, 13, 8, 12, 11, 10]
48
- end
49
-
50
- it 'sorts results based on the sort option desc' do
51
- finder = finder_with_sort 'price desc'
52
- expect(finder.results.map { |n| n[:price] }).to eq [14, 13, 12, 11, 10, 8]
53
- end
54
-
55
- it 'sorts results based on the sort option asc' do
56
- finder = finder_with_sort 'price asc'
57
- expect(finder.results.map { |n| n[:price] }).to eq [8, 10, 11, 12, 13, 14]
58
- end
59
-
60
- it 'defaults to original sorted hash' do
61
- finder = finder_with_sort
62
- expect(finder.results.map { |n| n[:name] }).to eq ['Name0', 'Name1', 'Name2', 'Name3', 'Name4', 'Name3']
63
- end
64
-
65
- it 'ignores invalid sort values' do
66
- finder = finder_with_sort 'invalid attribute'
67
- expect { finder.results.to_a }.not_to raise_error
68
- end
69
- end
70
-
71
- describe 'sorting by multiple' do
72
-
73
- it 'sorts by multiple columns name asc and price asc' do
74
- finder = finder_with_sort 'name asc, price asc'
75
- expect(finder.results.map { |n| n[:name] }).to eq ['Name0', 'Name1', 'Name2', 'Name3', 'Name3', 'Name4']
76
- expect(finder.results.map { |n| n[:price] }).to eq [10, 11, 12, 8, 13, 14]
77
- end
78
-
79
- it 'sorts by multiple columns name asc and price desc' do
80
- finder = finder_with_sort 'name asc, price desc'
81
- expect(finder.results.map { |n| n[:name] }).to eq ['Name0', 'Name1', 'Name2', 'Name3', 'Name3', 'Name4']
82
- expect(finder.results.map { |n| n[:price] }).to eq [10, 11, 12, 13, 8, 14]
83
- end
84
-
85
- it 'sorts by multiple columns name desc and price desc' do
86
- finder = finder_with_sort 'name desc, price desc'
87
- expect(finder.results.map { |n| n[:name] }).to eq ['Name4', 'Name3', 'Name3', 'Name2', 'Name1', 'Name0']
88
- expect(finder.results.map { |n| n[:price] }).to eq [14, 13, 8, 12, 11, 10]
89
- end
90
- end
91
-
92
- it_behaves_like 'a sorting feature'
93
- end
94
- end
95
- end
96
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Trailblazer
4
- class Finder
5
- describe Features do
6
- def define_finder_class(&block)
7
- Class.new do
8
- include Trailblazer::Finder::Base
9
- include Trailblazer::Finder::Features
10
-
11
- instance_eval(&block) if block_given?
12
- end
13
- end
14
-
15
- it '.adapters' do
16
- finder_class = define_finder_class do
17
- entity_type { 'entity_type' }
18
- end
19
-
20
- expect(finder_class).to respond_to(:features)
21
- end
22
-
23
- describe Paging do
24
- it 'can load Paging feature' do
25
- expect do
26
- define_finder_class do
27
- entity_type { 'entity_type' }
28
- features Paging
29
- end
30
- end.not_to raise_error
31
- end
32
- end
33
-
34
- describe Sorting do
35
- it 'can load Sorting feature' do
36
- expect do
37
- define_finder_class do
38
- entity_type { 'entity_type' }
39
- features Sorting
40
- end
41
- end.not_to raise_error
42
- end
43
- end
44
-
45
- it 'raises an error on non-existing feature' do
46
- expect do
47
- define_finder_class do
48
- entity_type { 'entity_type' }
49
- features Unknown
50
- end
51
- end.to raise_error NameError
52
- end
53
- end
54
- end
55
- end
@@ -1,133 +0,0 @@
1
- require 'spec_helper'
2
- require 'ostruct'
3
-
4
- module Trailblazer
5
- class Finder
6
- describe Filter do
7
- class TestFind
8
- include Trailblazer::Finder::Base
9
- include Trailblazer::Finder::Filter
10
-
11
- entity_type { [1, 2, 3, 4, 5] }
12
-
13
- filter_by :filter, defined_by: %w[odd even]
14
-
15
- private
16
-
17
- def apply_filter_with_odd(entity_type)
18
- entity_type.select(&:odd?)
19
- end
20
-
21
- def apply_filter_with_even(entity_type)
22
- entity_type.select(&:even?)
23
- end
24
-
25
- def handle_invalid_filter(_entity_type, value)
26
- "invalid filter - #{value}"
27
- end
28
- end
29
-
30
- it 'can filter by defined values' do
31
- expect(TestFind.results(filter: { filter: 'odd' })).to eq [1, 3, 5]
32
- expect(TestFind.results(filter: { filter: 'even' })).to eq [2, 4]
33
- end
34
-
35
- it 'ignores blank values' do
36
- expect(TestFind.results(filter: { filter: nil })).to eq [1, 2, 3, 4, 5]
37
- expect(TestFind.results(filter: { filter: '' })).to eq [1, 2, 3, 4, 5]
38
- end
39
-
40
- it 'handles wrongly defined values' do
41
- expect(TestFind.results(filter: { filter: 'foo' })).to eq 'invalid filter - foo'
42
- end
43
-
44
- it 'raises when block is passed with defined filter' do
45
- expect do
46
- Class.new do
47
- include Trailblazer::Finder::Base
48
- include Trailblazer::Finder::Filter
49
-
50
- filter_by(:filter, defined_by: %w[a b]) { |_entity_type, _value| nil }
51
- end
52
- end.to raise_error Trailblazer::Finder::Error::BlockIgnored
53
- end
54
-
55
- it 'raises when :with is passed with defined filter_by' do
56
- expect do
57
- Class.new do
58
- include Trailblazer::Finder::Base
59
- include Trailblazer::Finder::Filter
60
-
61
- filter_by :filter, defined_by: %w[a b], with: :method_name
62
- end
63
- end.to raise_error Trailblazer::Finder::Error::WithIgnored
64
- end
65
- end
66
-
67
- describe Filter::Handler do
68
- describe 'apply_filter' do
69
- def new_object(&block)
70
- klass = Class.new(&block)
71
- klass.new
72
- end
73
-
74
- def call(object: nil, filter_by: nil, defined_bys: nil, entity_type: nil, value:)
75
- described_class.apply_filter(
76
- object: object || new_object,
77
- filter_by: filter_by || 'filter_by',
78
- defined_bys: defined_bys || [value],
79
- entity_type: entity_type || [],
80
- value: value
81
- )
82
- end
83
-
84
- it 'filters by methods based on the defined value' do
85
- object = new_object do
86
- private
87
-
88
- def apply_select_with_name(entity_type)
89
- entity_type.select { |value| value == 'name' }
90
- end
91
-
92
- def apply_select_with_age(entity_type)
93
- entity_type.select { |value| value == 'age' }
94
- end
95
- end
96
-
97
- entity_type = %w[name age location]
98
-
99
- expect(call(object: object, filter_by: 'select', entity_type: entity_type, value: 'name')).to eq %w[name]
100
- expect(call(object: object, filter_by: 'select', entity_type: entity_type, value: 'age')).to eq %w[age]
101
- end
102
-
103
- it 'raises NoMethodError when object can not handle defined method' do
104
- expect { call(defined_bys: ['a'], value: 'a') }.to raise_error NoMethodError
105
- end
106
-
107
- it 'raises error when value is not defined' do
108
- expect { call(defined_bys: [], value: 'invalid') }.to raise_error Trailblazer::Finder::Error::InvalidDefinedByValue
109
- end
110
-
111
- it 'can delegate missing defined value to object' do
112
- object = new_object do
113
- def handle_invalid_filter_by(_entity_type, value)
114
- "handles #{value} value"
115
- end
116
- end
117
-
118
- expect(call(object: object, defined_bys: [], value: 'invalid')).to eq 'handles invalid value'
119
- end
120
-
121
- it 'can delegate missing defined value to object (cath all)' do
122
- object = new_object do
123
- def handle_invalid_defined_by(filter_by, _entity_type, value)
124
- "handles #{value} value for #{filter_by}"
125
- end
126
- end
127
-
128
- expect(call(object: object, defined_bys: [], value: 'invalid')).to eq 'handles invalid value for filter_by'
129
- end
130
- end
131
- end
132
- end
133
- end
@@ -1,72 +0,0 @@
1
- require 'spec_helper'
2
- require 'ostruct'
3
-
4
- module Trailblazer
5
- describe Finder::Find do
6
- describe '.params' do
7
- it 'returns the passed params' do
8
- finder = Finder::Find.new('entity_type', 'params', {})
9
- expect(finder.params).to eq 'params'
10
- end
11
- end
12
-
13
- describe '.param' do
14
- it 'returns the param value' do
15
- finder = Finder::Find.new('entity_type', { name: 'value' }, {})
16
- expect(finder.param(:name)).to eq 'value'
17
- end
18
- end
19
-
20
- describe '.query' do
21
- it 'returns filtered result' do
22
- actions = {
23
- min: ->(entity_type, min) { entity_type.select { |v| v > min } }
24
- }
25
-
26
- finder = Finder::Find.new [1, 2, 3], { min: 2 }, actions
27
- expect(finder.query(Object.new)).to eq [3]
28
- end
29
-
30
- it 'applies actions to params' do
31
- actions = {
32
- min: ->(entity_type, min) { entity_type.select { |v| v > min } },
33
- max: ->(entity_type, max) { entity_type.select { |v| v < max } }
34
- }
35
-
36
- finder = Finder::Find.new [1, 2, 3, 4, 5], { min: 2, max: 5 }, actions
37
- expect(finder.query(Object.new)).to eq [3, 4]
38
- end
39
-
40
- it 'handles nil returned from action' do
41
- actions = {
42
- odd: ->(entity_type, odd) { entity_type.select(&:odd?) if odd }
43
- }
44
-
45
- finder = Finder::Find.new [1, 2, 3, 4, 5], { odd: false }, actions
46
- expect(finder.query(Object.new)).to eq [1, 2, 3, 4, 5]
47
- end
48
-
49
- it 'executes action in the passed context' do
50
- actions = {
51
- finder: ->(entity_type, _) { entity_type.select { |v| v == target_value } }
52
- }
53
-
54
- context = OpenStruct.new target_value: 2
55
-
56
- finder = Finder::Find.new [1, 2, 3, 4, 5], { finder: true }, actions
57
- expect(finder.query(context)).to eq [2]
58
- end
59
- end
60
-
61
- describe '.count' do
62
- it 'counts the results of the query' do
63
- actions = {
64
- value: ->(entity_type, value) { entity_type.select { |v| v == value } }
65
- }
66
-
67
- finder = Finder::Find.new [1, 2, 3], { value: 2 }, actions
68
- expect(finder.count(Object.new)).to eq 1
69
- end
70
- end
71
- end
72
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Trailblazer
4
- class Finder
5
- module Utils
6
- describe Extra do
7
- describe '.deep_copy' do
8
- it 'returns a deep copy on the given object' do
9
- original = {
10
- array: [1, 2, 3],
11
- hash: { key: 'value' },
12
- boolean: true,
13
- number: 1,
14
- null: nil
15
- }
16
-
17
- deep_copy = Finder::Utils::Extra.deep_copy(original)
18
-
19
- original[:array][0] = 42
20
- original[:hash][:key] = 'other value'
21
-
22
- expect(deep_copy).to eq(
23
- array: [1, 2, 3],
24
- hash: { key: 'value' },
25
- boolean: true,
26
- number: 1,
27
- null: nil
28
- )
29
- end
30
- end
31
-
32
- describe '.ensure_included' do
33
- it 'works' do
34
- str = Utils::Extra.ensure_included '1 2'.to_s.split(' ', 2).last, %w[1]
35
- expect(str).to eq('1')
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Trailblazer
4
- class Finder
5
- module Utils
6
- describe Params do
7
- describe '.slice_keys' do
8
- it 'selects only given keys' do
9
- hash = Finder::Utils::Params.slice_keys({ a: 1, b: 2, c: 3 }, %i[a b])
10
- expect(hash).to eq a: 1, b: 2
11
- end
12
-
13
- it 'ignores not existing keys' do
14
- hash = Finder::Utils::Params.slice_keys({}, %i[a b])
15
- expect(hash).to eq({})
16
- end
17
- end
18
-
19
- describe '.normalize_params' do
20
- it 'combines defaults and filters' do
21
- expect(Finder::Utils::Params.normalize_params({ 'a' => 1, 'b' => 2 }, { a: 2 }, %w[a b])).to eq 'a' => 2, 'b' => 2
22
- end
23
-
24
- it 'excludes non specified keys' do
25
- expect(Finder::Utils::Params.normalize_params({ 'a' => 1 }, { b: 2 }, %w[a])).to eq 'a' => 1
26
- end
27
-
28
- it 'handles missing defaults' do
29
- expect(Finder::Utils::Params.normalize_params(nil, { a: 1 }, %w[a])).to eq 'a' => 1
30
- end
31
-
32
- it 'handles missing filters' do
33
- expect(Finder::Utils::Params.normalize_params(nil, nil, ['a'])).to eq({})
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Trailblazer
4
- class Finder
5
- module Utils
6
- describe Parse do
7
- describe '.parse_date' do
8
- it 'returns when value is a date' do
9
- expect(Finder::Utils::Parse.date('2018-01-01')).to eq '2018-01-01'
10
- end
11
-
12
- it 'returns when value is a screwed up date like 02-2018-01 10:10:10' do
13
- expect(Finder::Utils::Parse.date('02-2018-01 10:10')).to eq '2018-01-02'
14
- end
15
-
16
- it 'returns nil value is not date worthy' do
17
- expect(Finder::Utils::Parse.date('Unknown')).to eq nil
18
- end
19
- end
20
-
21
- describe '.escape_term' do
22
- it 'returns escaped value' do
23
- expect(Finder::Utils::Parse.term('term')).to eq '%term%'
24
- end
25
-
26
- it 'returns mutliple escaped values' do
27
- expect(Finder::Utils::Parse.term('term term')).to eq '%term%term%'
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end