normalizy 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -5
- data/lib/normalizy/filters/money.rb +1 -1
- data/lib/normalizy/version.rb +1 -1
- data/spec/normalizy/extensions/filters/date_spec.rb +3 -3
- data/spec/normalizy/extensions/filters/money_spec.rb +19 -11
- data/spec/normalizy/extensions/filters/number_spec.rb +1 -1
- data/spec/normalizy/extensions/filters/percent_spec.rb +6 -6
- data/spec/normalizy/extensions/filters/slug_spec.rb +3 -3
- data/spec/normalizy/extensions/filters/strip_spec.rb +4 -4
- data/spec/normalizy/extensions/model_spec.rb +17 -17
- data/spec/normalizy/extensions/normalizy_rules_spec.rb +17 -17
- data/spec/normalizy/filters/money_spec.rb +122 -8
- data/spec/normalizy/rspec/matcher/description_spec.rb +2 -2
- data/spec/normalizy/rspec/matcher/failure_message_spec.rb +4 -4
- data/spec/normalizy/rspec/matcher/failure_message_when_negated_spec.rb +2 -2
- data/spec/normalizy/rspec/matcher/matches_spec.rb +11 -11
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc428c7ca5535d3d9cf75e77752380d999747578e4dac3cdef425106a2d7287
|
4
|
+
data.tar.gz: 66a390c2bc1e7c9fed41a8587615773b70e7523dea9938f96059cf23a825d053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adfd4a6e1615e61738845fc2b7861bf5d59fb0228586f176132513c1741c61479892d865b6e5081f681771d0e8faaad64fd9ffeae20191b8266c4629decdf577
|
7
|
+
data.tar.gz: d7e5d1e5beb1940b8c28a1bc1af1e6d9f95c574e0ad906feecb3e995dea7ca835865febd50f5c0e383124fbc9f3bdaaf476d657a4948e8938d3a9398aff825b3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/wbotelhos/normalizy.svg)](https://travis-ci.org/wbotelhos/normalizy)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/normalizy.svg)](https://badge.fury.io/rb/normalizy)
|
5
|
-
[![
|
5
|
+
[![Patreon](https://img.shields.io/badge/donate-%3C3-brightgreen.svg)](https://www.patreon.com/wbotelhos)
|
6
6
|
|
7
7
|
Attribute normalizer for ActiveRecord.
|
8
8
|
|
@@ -679,7 +679,3 @@ it { is_expected.to normalizy(:email).with %i[downcase squish] }
|
|
679
679
|
```ruby
|
680
680
|
it { is_expected.to normalizy(:email).with(trim: { side: :left }) }
|
681
681
|
```
|
682
|
-
|
683
|
-
## Love it!
|
684
|
-
|
685
|
-
Via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=normalizy) or [Gratipay](https://gratipay.com/normalizy). Thanks! (:
|
data/lib/normalizy/version.rb
CHANGED
@@ -3,19 +3,19 @@
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
5
|
RSpec.describe ModelDate, 'filters:date' do
|
6
|
-
|
6
|
+
it do
|
7
7
|
expected = Time.new(1984, 10, 23, 0, 0, 0, 0)
|
8
8
|
|
9
9
|
expect(described_class.create(date: '1984-10-23').date).to eq expected
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
it do
|
13
13
|
expected = Time.new(1984, 10, 23, 0, 0, 0, 0)
|
14
14
|
|
15
15
|
expect(described_class.create(date_format: '84/10/23').date_format).to eq expected
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
it do
|
19
19
|
hours = ActiveSupport::TimeZone['Brasilia'].utc_offset / 3600.0
|
20
20
|
expected = Time.new(1984, 10, 23, 0, 0, 0, 0) + (hours.hours * -1)
|
21
21
|
|
@@ -3,28 +3,36 @@
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
5
|
RSpec.describe ModelMoney, 'filters:money' do
|
6
|
-
|
6
|
+
it do
|
7
7
|
expect(described_class.create(text: '$ 42.00').text).to eq '42.00'
|
8
8
|
expect(described_class.create(text: '$ 42.10').text).to eq '42.10'
|
9
|
+
|
10
|
+
expect(described_class.create(text: '$ -42.00').text).to eq '-42.00'
|
11
|
+
expect(described_class.create(text: '$ -42.10').text).to eq '-42.10'
|
9
12
|
end
|
10
13
|
|
11
|
-
|
12
|
-
expect(described_class.create(cents_type: '$ 42.33').cents_type).to
|
14
|
+
it do
|
15
|
+
expect(described_class.create(cents_type: '$ 42.33').cents_type).to eq '4233'
|
16
|
+
expect(described_class.create(cents_type: '$ -42.33').cents_type).to eq '-4233'
|
13
17
|
end
|
14
18
|
|
15
|
-
|
16
|
-
expect(described_class.create(cast_to_i: '$ 42.00').cast_to_i).to
|
19
|
+
it do
|
20
|
+
expect(described_class.create(cast_to_i: '$ 42.00').cast_to_i).to be 42
|
21
|
+
expect(described_class.create(cast_to_i: '$ -42.00').cast_to_i).to be -42
|
17
22
|
end
|
18
23
|
|
19
|
-
|
20
|
-
expect(described_class.create(cast_to_d: '$ 1.23').cast_to_d).to
|
24
|
+
it do
|
25
|
+
expect(described_class.create(cast_to_d: '$ 1.23').cast_to_d).to eq 1.23
|
26
|
+
expect(described_class.create(cast_to_d: '$ -1.23').cast_to_d).to eq -1.23
|
21
27
|
end
|
22
28
|
|
23
|
-
|
24
|
-
expect(described_class.create(cents_type_and_cast_to_f: '$ 42.00').cents_type_and_cast_to_f).to
|
29
|
+
it do
|
30
|
+
expect(described_class.create(cents_type_and_cast_to_f: '$ 42.00').cents_type_and_cast_to_f).to eq 4200.0
|
31
|
+
expect(described_class.create(cents_type_and_cast_to_f: '$ -42.00').cents_type_and_cast_to_f).to eq -4200.0
|
25
32
|
end
|
26
33
|
|
27
|
-
|
28
|
-
expect(described_class.create(cents_type_and_cast_to_i: '$ 42.00').cents_type_and_cast_to_i).to
|
34
|
+
it do
|
35
|
+
expect(described_class.create(cents_type_and_cast_to_i: '$ 42.00').cents_type_and_cast_to_i).to eq 4200
|
36
|
+
expect(described_class.create(cents_type_and_cast_to_i: '$ -42.00').cents_type_and_cast_to_i).to eq -4200
|
29
37
|
end
|
30
38
|
end
|
@@ -3,28 +3,28 @@
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
5
|
RSpec.describe ModelPercent, 'filters:percent' do
|
6
|
-
|
6
|
+
it do
|
7
7
|
expect(described_class.create(text: '42.00 %').text).to eq '42.00'
|
8
8
|
expect(described_class.create(text: '42.10 %').text).to eq '42.10'
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
it do
|
12
12
|
expect(described_class.create(cents_type: '42.33 %').cents_type).to eq '4233'
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
it do
|
16
16
|
expect(described_class.create(cast_to_i: '42.00 %').cast_to_i).to be 42
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it do
|
20
20
|
expect(described_class.create(cast_to_d: '1.23 %').cast_to_d).to eq 1.23
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
it do
|
24
24
|
expect(described_class.create(cents_type_and_cast_to_f: '42.00 %').cents_type_and_cast_to_f).to eq 4200.0
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
it do
|
28
28
|
expect(described_class.create(cents_type_and_cast_to_i: '42.00 %').cents_type_and_cast_to_i).to eq 4200
|
29
29
|
end
|
30
30
|
end
|
@@ -6,9 +6,9 @@ RSpec.describe ModelSlug, 'filters:slug' do
|
|
6
6
|
from = 'The Títle'
|
7
7
|
to = 'the-title'
|
8
8
|
|
9
|
-
|
9
|
+
it { expect(described_class.create(permalink: from).permalink).to eq to }
|
10
10
|
|
11
|
-
|
11
|
+
it { expect(described_class.create(title: from).slug).to eq to }
|
12
12
|
|
13
|
-
|
13
|
+
it { expect(described_class.create(title: from).title).to eq from }
|
14
14
|
end
|
@@ -3,19 +3,19 @@
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
5
|
RSpec.describe ModelStrip, 'filters:strip' do
|
6
|
-
|
6
|
+
it do
|
7
7
|
expect(described_class.create(strip: ' Botelho ').strip).to eq 'Botelho'
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
it do
|
11
11
|
expect(described_class.create(strip_side_left: ' Botelho ').strip_side_left).to eq 'Botelho '
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
it do
|
15
15
|
expect(described_class.create(strip_side_right: ' Botelho ').strip_side_right).to eq ' Botelho'
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
it do
|
19
19
|
expect(described_class.create(strip_side_both: ' Botelho ').strip_side_both).to eq 'Botelho'
|
20
20
|
end
|
21
21
|
end
|
@@ -4,13 +4,13 @@ require 'rails_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe '#apply_normalizy' do
|
6
6
|
context 'when object has no normalizy' do
|
7
|
-
|
7
|
+
it do
|
8
8
|
expect(Model.create(none: ' Botelho ').none).to eq ' Botelho '
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'when object has normalizy' do
|
13
|
-
|
13
|
+
it do
|
14
14
|
Normalizy.configure do |config|
|
15
15
|
config.default_filters = [:squish]
|
16
16
|
end
|
@@ -18,41 +18,41 @@ RSpec.describe '#apply_normalizy' do
|
|
18
18
|
expect(Model.create(default: ' Botelho ').default).to eq 'Botelho'
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
it do
|
22
22
|
expect(Model.create(block: 'Botelho').block).to eq 'BOTELHO'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'when a filter is given' do
|
27
|
-
|
27
|
+
it do
|
28
28
|
expect(Model.create(symbol: ' Bote lho ').symbol).to eq 'Bote lho'
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
it do
|
32
32
|
expect(Model.create(array_symbol: ' Bote lho ').array_symbol).to eq 'Bote lho'
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
it do
|
36
36
|
expect(Model.create(array_symbols: ' Bote lho ').array_symbols).to eq 'bote lho'
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
it do
|
40
40
|
expect(Model.create(hash_no_args: ' Bote lho ').hash_no_args).to eq 'Bote lho'
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
it do
|
44
44
|
expect(Model.create(hash_with_args: ' Botelho ').hash_with_args).to eq 'Botelho '
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
it do
|
48
48
|
expect(Model.create(module_one_arg: 'Fuck').module_one_arg).to eq 'filtered'
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
it do
|
52
52
|
expect(Model.create(module_two_args: 'Botelho').module_two_args).to eq 'module_two_args, Botelho, Model'
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
it do
|
56
56
|
Normalizy.configure do |config|
|
57
57
|
config.add :blacklist, Normalizy::Filters::Block
|
58
58
|
end
|
@@ -60,11 +60,11 @@ RSpec.describe '#apply_normalizy' do
|
|
60
60
|
expect(Model.create(module_and_block: 'Botelho').module_and_block).to eq 'BOTELHO'
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
it do
|
64
64
|
expect(Model.create(method_with_no_options_field: 'Botelho').method_with_no_options_field).to eq 'Botelho'
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
it do
|
68
68
|
expect(Model.create(method_with_options_field: 'Botelho').method_with_options_field).to eq [
|
69
69
|
'Botelho',
|
70
70
|
{
|
@@ -75,18 +75,18 @@ RSpec.describe '#apply_normalizy' do
|
|
75
75
|
].join ', '
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
it do
|
79
79
|
expect(Model.create(native: 'Botelho').native).to eq '["Botelho"]'
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
it do
|
83
83
|
expect(Model.create(multiple: 'BoteLho').multiple).to eq 'bote lho'
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
context 'when assign is made via set' do
|
88
88
|
context 'with no save' do
|
89
|
-
|
89
|
+
it do
|
90
90
|
object = Model.new
|
91
91
|
object.symbol = ' Bote lho '
|
92
92
|
|
@@ -95,7 +95,7 @@ RSpec.describe '#apply_normalizy' do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
context 'with save' do
|
98
|
-
|
98
|
+
it do
|
99
99
|
object = Model.new
|
100
100
|
object.symbol = ' Bote lho '
|
101
101
|
object.save
|
@@ -14,19 +14,19 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
it do
|
18
18
|
model.normalizy :name
|
19
19
|
|
20
20
|
expect(model.normalizy_rules).to eq(name: [{ block: nil, options: {}, rules: nil }])
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
it do
|
24
24
|
model.normalizy :name, with: :upcase
|
25
25
|
|
26
26
|
expect(model.normalizy_rules).to eq(name: [{ block: nil, options: {}, rules: :upcase }])
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
it do
|
30
30
|
expected = { name: [{ block: nil, options: {}, rules: [:upcase, 'blank', { trim: { side: :left } }] }] }
|
31
31
|
|
32
32
|
model.normalizy :name, with: [:upcase, 'blank', { trim: { side: :left } }]
|
@@ -34,7 +34,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
34
34
|
expect(model.normalizy_rules).to eq expected
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
it do
|
38
38
|
model.normalizy :name, with: [:upcase, { trim: { side: :left } }]
|
39
39
|
model.normalizy :name, with: :squish
|
40
40
|
model.normalizy :name, with: [:upcase, { trim: { side: :right } }]
|
@@ -50,7 +50,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
it do
|
54
54
|
model.normalizy :email, :name
|
55
55
|
|
56
56
|
expect(model.normalizy_rules).to eq(
|
@@ -59,7 +59,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
it do
|
63
63
|
model.normalizy :email, :name, with: :upcase
|
64
64
|
|
65
65
|
expect(model.normalizy_rules).to eq(
|
@@ -68,7 +68,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
68
68
|
)
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
it do
|
72
72
|
model.normalizy :email, :name, with: [:upcase, :blank, { trim: { side: :left } }]
|
73
73
|
|
74
74
|
expect(model.normalizy_rules).to eq(
|
@@ -77,7 +77,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
77
77
|
)
|
78
78
|
end
|
79
79
|
|
80
|
-
|
80
|
+
it do
|
81
81
|
model.normalizy :email, :name, with: [:upcase, { trim: { side: :left } }]
|
82
82
|
model.normalizy :email, :name, with: :squish
|
83
83
|
model.normalizy :email, :name, with: [:upcase, { trim: { side: :right } }]
|
@@ -107,25 +107,25 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
|
110
|
+
it do
|
111
111
|
model.normalizy :name
|
112
112
|
|
113
113
|
expect(model.normalizy_rules).to eq(name: [{ block: nil, options: {}, rules: nil }])
|
114
114
|
end
|
115
115
|
|
116
|
-
|
116
|
+
it do
|
117
117
|
model.normalizy :name, with: :upcase
|
118
118
|
|
119
119
|
expect(model.normalizy_rules).to eq(name: [{ block: nil, options: {}, rules: :upcase }])
|
120
120
|
end
|
121
121
|
|
122
|
-
|
122
|
+
it do
|
123
123
|
model.normalizy :name, with: %i[upcase blank]
|
124
124
|
|
125
125
|
expect(model.normalizy_rules).to eq(name: [{ block: nil, options: {}, rules: %i[upcase blank] }])
|
126
126
|
end
|
127
127
|
|
128
|
-
|
128
|
+
it do
|
129
129
|
model.normalizy :name, with: :upcase
|
130
130
|
model.normalizy :name, with: :squish
|
131
131
|
model.normalizy :name, with: :upcase
|
@@ -139,7 +139,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
139
139
|
)
|
140
140
|
end
|
141
141
|
|
142
|
-
|
142
|
+
it do
|
143
143
|
model.normalizy :email, :name
|
144
144
|
|
145
145
|
expect(model.normalizy_rules).to eq(
|
@@ -148,7 +148,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
148
148
|
)
|
149
149
|
end
|
150
150
|
|
151
|
-
|
151
|
+
it do
|
152
152
|
model.normalizy :email, :name, with: :upcase
|
153
153
|
|
154
154
|
expect(model.normalizy_rules).to eq(
|
@@ -157,7 +157,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
157
157
|
)
|
158
158
|
end
|
159
159
|
|
160
|
-
|
160
|
+
it do
|
161
161
|
model.normalizy :email, :name, with: %i[upcase blank]
|
162
162
|
|
163
163
|
expect(model.normalizy_rules).to eq(
|
@@ -166,7 +166,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
166
166
|
)
|
167
167
|
end
|
168
168
|
|
169
|
-
|
169
|
+
it do
|
170
170
|
model.normalizy :email, :name, with: :upcase
|
171
171
|
model.normalizy :email, :name, with: :squish
|
172
172
|
model.normalizy :email, :name, with: :upcase
|
@@ -189,7 +189,7 @@ RSpec.describe Normalizy::Extension, ':normalizy_rules' do
|
|
189
189
|
context 'when block is given' do
|
190
190
|
let!(:block) { ->(value) { value.downcase } }
|
191
191
|
|
192
|
-
|
192
|
+
it do
|
193
193
|
model.normalizy :name, &block
|
194
194
|
|
195
195
|
expect(model.normalizy_rules[:name][0][:block]).to eq block
|
@@ -6,12 +6,18 @@ RSpec.describe Normalizy::Filters::Money do
|
|
6
6
|
describe 'default options' do
|
7
7
|
it { expect(subject.call('')).to eq nil }
|
8
8
|
|
9
|
-
it { expect(subject.call(1)).to
|
10
|
-
it { expect(subject.call(1.70)).to
|
11
|
-
it { expect(subject.call(103.70)).to
|
12
|
-
it { expect(subject.call(1030.70)).to
|
9
|
+
it { expect(subject.call(1)).to be 1 }
|
10
|
+
it { expect(subject.call(1.70)).to be 1.70 }
|
11
|
+
it { expect(subject.call(103.70)).to be 103.70 }
|
12
|
+
it { expect(subject.call(1030.70)).to be 1030.70 }
|
13
13
|
it { expect(subject.call(10_300.70)).to be 10_300.70 }
|
14
14
|
|
15
|
+
it { expect(subject.call(-1)).to be -1 }
|
16
|
+
it { expect(subject.call(-1.70)).to be -1.70 }
|
17
|
+
it { expect(subject.call(-103.70)).to be -103.70 }
|
18
|
+
it { expect(subject.call(-1030.70)).to be -1030.70 }
|
19
|
+
it { expect(subject.call(-10_300.70)).to be -10_300.70 }
|
20
|
+
|
15
21
|
it { expect(subject.call('0')).to eq '0.00' }
|
16
22
|
it { expect(subject.call('100')).to eq '100.00' }
|
17
23
|
it { expect(subject.call('100.0')).to eq '100.00' }
|
@@ -20,12 +26,27 @@ RSpec.describe Normalizy::Filters::Money do
|
|
20
26
|
it { expect(subject.call('1030.70')).to eq '1030.70' }
|
21
27
|
it { expect(subject.call('10300.70')).to eq '10300.70' }
|
22
28
|
|
29
|
+
it { expect(subject.call('-0')).to eq '-0.00' }
|
30
|
+
it { expect(subject.call('-100')).to eq '-100.00' }
|
31
|
+
it { expect(subject.call('-100.0')).to eq '-100.00' }
|
32
|
+
it { expect(subject.call('-1.70')).to eq '-1.70' }
|
33
|
+
it { expect(subject.call('-103.70')).to eq '-103.70' }
|
34
|
+
it { expect(subject.call('-1030.70')).to eq '-1030.70' }
|
35
|
+
it { expect(subject.call('-10300.70')).to eq '-10300.70' }
|
36
|
+
|
23
37
|
it { expect(subject.call('$ 0.01')).to eq '0.01' }
|
24
38
|
it { expect(subject.call('$ 1')).to eq '1.00' }
|
25
39
|
it { expect(subject.call('$ 1.70')).to eq '1.70' }
|
26
40
|
it { expect(subject.call('$ 103.70')).to eq '103.70' }
|
27
41
|
it { expect(subject.call('$ 1030.70')).to eq '1030.70' }
|
28
42
|
it { expect(subject.call('$ 10300.70')).to eq '10300.70' }
|
43
|
+
|
44
|
+
it { expect(subject.call('$ -0.01')).to eq '-0.01' }
|
45
|
+
it { expect(subject.call('$ -1')).to eq '-1.00' }
|
46
|
+
it { expect(subject.call('$ -1.70')).to eq '-1.70' }
|
47
|
+
it { expect(subject.call('$ -103.70')).to eq '-103.70' }
|
48
|
+
it { expect(subject.call('$ -1030.70')).to eq '-1030.70' }
|
49
|
+
it { expect(subject.call('$ -10300.70')).to eq '-10300.70' }
|
29
50
|
end
|
30
51
|
|
31
52
|
describe 'type' do
|
@@ -37,8 +58,15 @@ RSpec.describe Normalizy::Filters::Money do
|
|
37
58
|
it { expect(subject.call(1030.70 , type: :cents)).to be 1030.70 }
|
38
59
|
it { expect(subject.call(10_300.70, type: :cents)).to be 10_300.70 }
|
39
60
|
|
61
|
+
it { expect(subject.call(-1 , type: :cents)).to be -1 }
|
62
|
+
it { expect(subject.call(-1.70 , type: :cents)).to be -1.70 }
|
63
|
+
it { expect(subject.call(-103.70 , type: :cents)).to be -103.70 }
|
64
|
+
it { expect(subject.call(-1030.70 , type: :cents)).to be -1030.70 }
|
65
|
+
it { expect(subject.call(-10_300.70, type: :cents)).to be -10_300.70 }
|
66
|
+
|
40
67
|
context 'with different separator' do
|
41
|
-
it { expect(subject.call('1,7',
|
68
|
+
it { expect(subject.call('1,7', separator: ',', type: :cents)).to eq '170' }
|
69
|
+
it { expect(subject.call('-1,7', separator: ',', type: :cents)).to eq '-170' }
|
42
70
|
end
|
43
71
|
|
44
72
|
context 'with no decimal precision' do
|
@@ -46,10 +74,18 @@ RSpec.describe Normalizy::Filters::Money do
|
|
46
74
|
it { expect(subject.call('10' , type: :cents)).to eq '10' }
|
47
75
|
it { expect(subject.call('100', type: :cents)).to eq '100' }
|
48
76
|
|
77
|
+
it { expect(subject.call('-1' , type: :cents)).to eq '-1' }
|
78
|
+
it { expect(subject.call('-10' , type: :cents)).to eq '-10' }
|
79
|
+
it { expect(subject.call('-100', type: :cents)).to eq '-100' }
|
80
|
+
|
49
81
|
context 'with float :cast' do
|
50
82
|
it { expect(subject.call('1' , cast: :to_f, type: :cents)).to eq 1.0 }
|
51
83
|
it { expect(subject.call('10' , cast: :to_f, type: :cents)).to eq 10.0 }
|
52
84
|
it { expect(subject.call('100', cast: :to_f, type: :cents)).to eq 100.0 }
|
85
|
+
|
86
|
+
it { expect(subject.call('-1' , cast: :to_f, type: :cents)).to eq -1.0 }
|
87
|
+
it { expect(subject.call('-10' , cast: :to_f, type: :cents)).to eq -10.0 }
|
88
|
+
it { expect(subject.call('-100', cast: :to_f, type: :cents)).to eq -100.0 }
|
53
89
|
end
|
54
90
|
end
|
55
91
|
|
@@ -59,21 +95,41 @@ RSpec.describe Normalizy::Filters::Money do
|
|
59
95
|
it { expect(subject.call('1030.7' , type: :cents)).to eq '103070' }
|
60
96
|
it { expect(subject.call('10300.7', type: :cents)).to eq '1030070' }
|
61
97
|
|
98
|
+
it { expect(subject.call('-1.7' , type: :cents)).to eq '-170' }
|
99
|
+
it { expect(subject.call('-103.7' , type: :cents)).to eq '-10370' }
|
100
|
+
it { expect(subject.call('-1030.7' , type: :cents)).to eq '-103070' }
|
101
|
+
it { expect(subject.call('-10300.7', type: :cents)).to eq '-1030070' }
|
102
|
+
|
62
103
|
it { expect(subject.call('$ 1.7' , type: :cents)).to eq '170' }
|
63
104
|
it { expect(subject.call('$ 103.7' , type: :cents)).to eq '10370' }
|
64
105
|
it { expect(subject.call('$ 1030.7' , type: :cents)).to eq '103070' }
|
65
106
|
it { expect(subject.call('$ 10300.7', type: :cents)).to eq '1030070' }
|
66
107
|
|
108
|
+
it { expect(subject.call('$ -1.7' , type: :cents)).to eq '-170' }
|
109
|
+
it { expect(subject.call('$ -103.7' , type: :cents)).to eq '-10370' }
|
110
|
+
it { expect(subject.call('$ -1030.7' , type: :cents)).to eq '-103070' }
|
111
|
+
it { expect(subject.call('$ -10300.7', type: :cents)).to eq '-1030070' }
|
112
|
+
|
67
113
|
context 'with float :cast' do
|
68
114
|
it { expect(subject.call('1.7' , cast: :to_f, type: :cents)).to be 170.0 }
|
69
115
|
it { expect(subject.call('103.7' , cast: :to_f, type: :cents)).to be 10_370.0 }
|
70
116
|
it { expect(subject.call('1030.7' , cast: :to_f, type: :cents)).to be 103_070.0 }
|
71
117
|
it { expect(subject.call('10300.7', cast: :to_f, type: :cents)).to be 1_030_070.0 }
|
72
118
|
|
119
|
+
it { expect(subject.call('-1.7' , cast: :to_f, type: :cents)).to be -170.0 }
|
120
|
+
it { expect(subject.call('-103.7' , cast: :to_f, type: :cents)).to be -10_370.0 }
|
121
|
+
it { expect(subject.call('-1030.7' , cast: :to_f, type: :cents)).to be -103_070.0 }
|
122
|
+
it { expect(subject.call('-10300.7', cast: :to_f, type: :cents)).to be -1_030_070.0 }
|
123
|
+
|
73
124
|
it { expect(subject.call('$ 1.7' , cast: :to_f, type: :cents)).to be 170.0 }
|
74
125
|
it { expect(subject.call('$ 103.7' , cast: :to_f, type: :cents)).to be 10_370.0 }
|
75
126
|
it { expect(subject.call('$ 1030.7' , cast: :to_f, type: :cents)).to be 103_070.0 }
|
76
127
|
it { expect(subject.call('$ 10300.7', cast: :to_f, type: :cents)).to be 1_030_070.0 }
|
128
|
+
|
129
|
+
it { expect(subject.call('$ -1.7' , cast: :to_f, type: :cents)).to be -170.0 }
|
130
|
+
it { expect(subject.call('$ -103.7' , cast: :to_f, type: :cents)).to be -10_370.0 }
|
131
|
+
it { expect(subject.call('$ -1030.7' , cast: :to_f, type: :cents)).to be -103_070.0 }
|
132
|
+
it { expect(subject.call('$ -10300.7', cast: :to_f, type: :cents)).to be -1_030_070.0 }
|
77
133
|
end
|
78
134
|
end
|
79
135
|
|
@@ -83,28 +139,49 @@ RSpec.describe Normalizy::Filters::Money do
|
|
83
139
|
it { expect(subject.call('1030.70' , type: :cents)).to eq '103070' }
|
84
140
|
it { expect(subject.call('10300.70', type: :cents)).to eq '1030070' }
|
85
141
|
|
142
|
+
it { expect(subject.call('-1.70' , type: :cents)).to eq '-170' }
|
143
|
+
it { expect(subject.call('-103.70' , type: :cents)).to eq '-10370' }
|
144
|
+
it { expect(subject.call('-1030.70' , type: :cents)).to eq '-103070' }
|
145
|
+
it { expect(subject.call('-10300.70', type: :cents)).to eq '-1030070' }
|
146
|
+
|
86
147
|
it { expect(subject.call('$ 1.70' , type: :cents)).to eq '170' }
|
87
148
|
it { expect(subject.call('$ 103.70' , type: :cents)).to eq '10370' }
|
88
149
|
it { expect(subject.call('$ 1030.70' , type: :cents)).to eq '103070' }
|
89
150
|
it { expect(subject.call('$ 10300.70', type: :cents)).to eq '1030070' }
|
90
151
|
|
152
|
+
it { expect(subject.call('$ -1.70' , type: :cents)).to eq '-170' }
|
153
|
+
it { expect(subject.call('$ -103.70' , type: :cents)).to eq '-10370' }
|
154
|
+
it { expect(subject.call('$ -1030.70' , type: :cents)).to eq '-103070' }
|
155
|
+
it { expect(subject.call('$ -10300.70', type: :cents)).to eq '-1030070' }
|
156
|
+
|
91
157
|
context 'with float :cast' do
|
92
158
|
it { expect(subject.call('1.70' , cast: :to_f, type: :cents)).to be 170.0 }
|
93
159
|
it { expect(subject.call('103.70' , cast: :to_f, type: :cents)).to be 10_370.0 }
|
94
160
|
it { expect(subject.call('1030.70' , cast: :to_f, type: :cents)).to be 103_070.0 }
|
95
161
|
it { expect(subject.call('10300.70', cast: :to_f, type: :cents)).to be 1_030_070.0 }
|
96
162
|
|
163
|
+
it { expect(subject.call('-1.70' , cast: :to_f, type: :cents)).to be -170.0 }
|
164
|
+
it { expect(subject.call('-103.70' , cast: :to_f, type: :cents)).to be -10_370.0 }
|
165
|
+
it { expect(subject.call('-1030.70' , cast: :to_f, type: :cents)).to be -103_070.0 }
|
166
|
+
it { expect(subject.call('-10300.70', cast: :to_f, type: :cents)).to be -1_030_070.0 }
|
167
|
+
|
97
168
|
it { expect(subject.call('$ 1.70' , cast: :to_f, type: :cents)).to be 170.0 }
|
98
169
|
it { expect(subject.call('$ 103.70' , cast: :to_f, type: :cents)).to be 10_370.0 }
|
99
170
|
it { expect(subject.call('$ 1030.70' , cast: :to_f, type: :cents)).to be 103_070.0 }
|
100
171
|
it { expect(subject.call('$ 10300.70', cast: :to_f, type: :cents)).to be 1_030_070.0 }
|
172
|
+
|
173
|
+
it { expect(subject.call('$ -1.70' , cast: :to_f, type: :cents)).to be -170.0 }
|
174
|
+
it { expect(subject.call('$ -103.70' , cast: :to_f, type: :cents)).to be -10_370.0 }
|
175
|
+
it { expect(subject.call('$ -1030.70' , cast: :to_f, type: :cents)).to be -103_070.0 }
|
176
|
+
it { expect(subject.call('$ -10300.70', cast: :to_f, type: :cents)).to be -1_030_070.0 }
|
101
177
|
end
|
102
178
|
end
|
103
179
|
end
|
104
180
|
|
105
181
|
describe 'separator' do
|
106
182
|
context 'when provided inline' do
|
107
|
-
it { expect(subject.call('R$ 0,01', separator: ',')).to
|
183
|
+
it { expect(subject.call('R$ 0,01', separator: ',')).to eq '0.01' }
|
184
|
+
it { expect(subject.call('R$ -0,01', separator: ',')).to eq '-0.01' }
|
108
185
|
end
|
109
186
|
|
110
187
|
context 'when provided I18n' do
|
@@ -113,11 +190,13 @@ RSpec.describe Normalizy::Filters::Money do
|
|
113
190
|
allow(I18n).to receive(:t).with('currency.format.precision', default: 2).and_return 2
|
114
191
|
end
|
115
192
|
|
116
|
-
it { expect(subject.call('1x2')).to
|
193
|
+
it { expect(subject.call('1x2')).to eq '1.20' }
|
194
|
+
it { expect(subject.call('-1x2')).to eq '-1.20' }
|
117
195
|
end
|
118
196
|
|
119
197
|
context 'when not provided' do
|
120
|
-
it { expect(subject.call('1.2')).to
|
198
|
+
it { expect(subject.call('1.2')).to eq '1.20' }
|
199
|
+
it { expect(subject.call('-1.2')).to eq '-1.20' }
|
121
200
|
end
|
122
201
|
end
|
123
202
|
|
@@ -126,6 +205,10 @@ RSpec.describe Normalizy::Filters::Money do
|
|
126
205
|
it { expect(subject.call('1' , cast: :to_f)).to eq 1.0 }
|
127
206
|
it { expect(subject.call('10' , cast: :to_f)).to eq 10.0 }
|
128
207
|
it { expect(subject.call('100', cast: :to_f)).to eq 100.0 }
|
208
|
+
|
209
|
+
it { expect(subject.call('-1' , cast: :to_f)).to eq -1.0 }
|
210
|
+
it { expect(subject.call('-10' , cast: :to_f)).to eq -10.0 }
|
211
|
+
it { expect(subject.call('-100', cast: :to_f)).to eq -100.0 }
|
129
212
|
end
|
130
213
|
|
131
214
|
context 'when value has one decimal precision' do
|
@@ -134,21 +217,41 @@ RSpec.describe Normalizy::Filters::Money do
|
|
134
217
|
it { expect(subject.call('1030.7' , cast: :to_f)).to eq 1030.7 }
|
135
218
|
it { expect(subject.call('10300.7', cast: :to_f)).to eq 10_300.7 }
|
136
219
|
|
220
|
+
it { expect(subject.call('-1.7' , cast: :to_f)).to eq -1.7 }
|
221
|
+
it { expect(subject.call('-103.7' , cast: :to_f)).to eq -103.7 }
|
222
|
+
it { expect(subject.call('-1030.7' , cast: :to_f)).to eq -1030.7 }
|
223
|
+
it { expect(subject.call('-10300.7', cast: :to_f)).to eq -10_300.7 }
|
224
|
+
|
137
225
|
it { expect(subject.call('$ 1.7' , cast: :to_f)).to eq 1.7 }
|
138
226
|
it { expect(subject.call('$ 103.7' , cast: :to_f)).to eq 103.7 }
|
139
227
|
it { expect(subject.call('$ 1030.7' , cast: :to_f)).to eq 1030.7 }
|
140
228
|
it { expect(subject.call('$ 10300.7', cast: :to_f)).to eq 10_300.7 }
|
141
229
|
|
230
|
+
it { expect(subject.call('$ -1.7' , cast: :to_f)).to eq -1.7 }
|
231
|
+
it { expect(subject.call('$ -103.7' , cast: :to_f)).to eq -103.7 }
|
232
|
+
it { expect(subject.call('$ -1030.7' , cast: :to_f)).to eq -1030.7 }
|
233
|
+
it { expect(subject.call('$ -10300.7', cast: :to_f)).to eq -10_300.7 }
|
234
|
+
|
142
235
|
context 'with calls cast' do
|
143
236
|
it { expect(subject.call('1.7' , cast: :to_f)).to be 1.7 }
|
144
237
|
it { expect(subject.call('103.7' , cast: :to_f)).to be 103.7 }
|
145
238
|
it { expect(subject.call('1030.7' , cast: :to_f)).to be 1030.7 }
|
146
239
|
it { expect(subject.call('10300.7', cast: :to_f)).to be 10_300.7 }
|
147
240
|
|
241
|
+
it { expect(subject.call('-1.7' , cast: :to_f)).to be -1.7 }
|
242
|
+
it { expect(subject.call('-103.7' , cast: :to_f)).to be -103.7 }
|
243
|
+
it { expect(subject.call('-1030.7' , cast: :to_f)).to be -1030.7 }
|
244
|
+
it { expect(subject.call('-10300.7', cast: :to_f)).to be -10_300.7 }
|
245
|
+
|
148
246
|
it { expect(subject.call('$ 1.7' , cast: :to_f)).to be 1.7 }
|
149
247
|
it { expect(subject.call('$ 103.7' , cast: :to_f)).to be 103.7 }
|
150
248
|
it { expect(subject.call('$ 1030.7' , cast: :to_f)).to be 1030.7 }
|
151
249
|
it { expect(subject.call('$ 10300.7', cast: :to_f)).to be 10_300.7 }
|
250
|
+
|
251
|
+
it { expect(subject.call('$ -1.7' , cast: :to_f)).to be -1.7 }
|
252
|
+
it { expect(subject.call('$ -103.7' , cast: :to_f)).to be -103.7 }
|
253
|
+
it { expect(subject.call('$ -1030.7' , cast: :to_f)).to be -1030.7 }
|
254
|
+
it { expect(subject.call('$ -10300.7', cast: :to_f)).to be -10_300.7 }
|
152
255
|
end
|
153
256
|
end
|
154
257
|
|
@@ -158,11 +261,22 @@ RSpec.describe Normalizy::Filters::Money do
|
|
158
261
|
it { expect(subject.call('1030.70' , cast: :to_f)).to be 1030.7 }
|
159
262
|
it { expect(subject.call('10300.70', cast: :to_f)).to be 10_300.7 }
|
160
263
|
|
264
|
+
it { expect(subject.call('-1.70' , cast: :to_f)).to be -1.7 }
|
265
|
+
it { expect(subject.call('-103.70' , cast: :to_f)).to be -103.7 }
|
266
|
+
it { expect(subject.call('-1030.70' , cast: :to_f)).to be -1030.7 }
|
267
|
+
it { expect(subject.call('-10300.70', cast: :to_f)).to be -10_300.7 }
|
268
|
+
|
161
269
|
it { expect(subject.call('$ 1' , cast: :to_f)).to be 1.0 }
|
162
270
|
it { expect(subject.call('$ 1.70' , cast: :to_f)).to be 1.7 }
|
163
271
|
it { expect(subject.call('$ 103.70' , cast: :to_f)).to be 103.7 }
|
164
272
|
it { expect(subject.call('$ 1030.70' , cast: :to_f)).to be 1030.7 }
|
165
273
|
it { expect(subject.call('$ 10300.70', cast: :to_f)).to be 10_300.7 }
|
274
|
+
|
275
|
+
it { expect(subject.call('$ -1' , cast: :to_f)).to be -1.0 }
|
276
|
+
it { expect(subject.call('$ -1.70' , cast: :to_f)).to be -1.7 }
|
277
|
+
it { expect(subject.call('$ -103.70' , cast: :to_f)).to be -103.7 }
|
278
|
+
it { expect(subject.call('$ -1030.70' , cast: :to_f)).to be -1030.7 }
|
279
|
+
it { expect(subject.call('$ -10300.70', cast: :to_f)).to be -10_300.7 }
|
166
280
|
end
|
167
281
|
end
|
168
282
|
end
|
@@ -6,7 +6,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.description' do
|
|
6
6
|
let!(:matcher) { described_class.new :name }
|
7
7
|
|
8
8
|
context 'with no :with expectation' do
|
9
|
-
|
9
|
+
it do
|
10
10
|
matcher.from :from
|
11
11
|
matcher.to :to
|
12
12
|
|
@@ -15,7 +15,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.description' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'with :with expectation' do
|
18
|
-
|
18
|
+
it do
|
19
19
|
matcher.with :blank
|
20
20
|
|
21
21
|
matcher.from :from
|
@@ -6,7 +6,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.failure_message' do
|
|
6
6
|
let!(:model) { Match }
|
7
7
|
|
8
8
|
context 'with no :with expectation' do
|
9
|
-
|
9
|
+
it do
|
10
10
|
matcher = described_class.new(:downcase_field)
|
11
11
|
|
12
12
|
matcher.from :from
|
@@ -18,7 +18,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.failure_message' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with :with expectation' do
|
21
|
-
|
21
|
+
it do
|
22
22
|
matcher = described_class.new(:alone)
|
23
23
|
|
24
24
|
matcher.with :missing
|
@@ -27,7 +27,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.failure_message' do
|
|
27
27
|
expect(matcher.failure_message).to eq %(expected: missing\n got: nil)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
it do
|
31
31
|
matcher = described_class.new(:downcase_field_array)
|
32
32
|
|
33
33
|
matcher.with :missing
|
@@ -36,7 +36,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.failure_message' do
|
|
36
36
|
expect(matcher.failure_message).to eq %(expected: missing\n got: downcase)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
it do
|
40
40
|
matcher = described_class.new(:trim_side_left)
|
41
41
|
|
42
42
|
matcher.with :missing
|
@@ -6,7 +6,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.failure_message_when_negated' do
|
|
6
6
|
let!(:model) { Match }
|
7
7
|
|
8
8
|
context 'with no :with expectation' do
|
9
|
-
|
9
|
+
it do
|
10
10
|
matcher = described_class.new(:downcase_field)
|
11
11
|
|
12
12
|
matcher.from 'from'
|
@@ -18,7 +18,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.failure_message_when_negated' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with :with expectation' do
|
21
|
-
|
21
|
+
it do
|
22
22
|
matcher = described_class.new(:downcase_field)
|
23
23
|
|
24
24
|
matcher.with :downcase
|
@@ -5,7 +5,7 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
6
6
|
let!(:object) { Match.new }
|
7
7
|
|
8
|
-
|
8
|
+
it do
|
9
9
|
matcher = described_class.new(:alone)
|
10
10
|
|
11
11
|
matcher.matches?(object)
|
@@ -14,7 +14,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
context 'when .with is called' do
|
17
|
-
|
17
|
+
it do
|
18
18
|
matcher = described_class.new(:alone)
|
19
19
|
|
20
20
|
matcher.with :missing
|
@@ -22,7 +22,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
22
22
|
expect(matcher.matches?(object)).to eq false
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
it do
|
26
26
|
matcher = described_class.new(:downcase_field)
|
27
27
|
|
28
28
|
matcher.with :downcase
|
@@ -30,7 +30,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
30
30
|
expect(matcher.matches?(object)).to eq true
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
it do
|
34
34
|
matcher = described_class.new(:trim_side_left)
|
35
35
|
|
36
36
|
matcher.with trim: { side: :left }
|
@@ -38,7 +38,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
38
38
|
expect(matcher.matches?(object)).to eq true
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
it do
|
42
42
|
matcher = described_class.new(:trim_side_left_array)
|
43
43
|
|
44
44
|
matcher.with trim: { side: :left }
|
@@ -46,7 +46,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
46
46
|
expect(matcher.matches?(object)).to eq true
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
it do
|
50
50
|
Normalizy.configure do |config|
|
51
51
|
config.default_filters = :squish
|
52
52
|
end
|
@@ -58,7 +58,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
58
58
|
expect(matcher.matches?(object)).to eq true
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
it do
|
62
62
|
Normalizy.configure do |config|
|
63
63
|
config.default_filters = [:squish]
|
64
64
|
end
|
@@ -70,7 +70,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
70
70
|
expect(matcher.matches?(object)).to eq true
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
it do
|
74
74
|
Normalizy.configure do |config|
|
75
75
|
config.default_filters = [{ strip: { side: :left } }]
|
76
76
|
end
|
@@ -82,7 +82,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
82
82
|
expect(matcher.matches?(object)).to eq true
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
it do
|
86
86
|
Normalizy.configure do |config|
|
87
87
|
config.default_filters = :squish
|
88
88
|
end
|
@@ -96,7 +96,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
context 'when .with is not called' do
|
99
|
-
|
99
|
+
it do
|
100
100
|
matcher = described_class.new(:alone)
|
101
101
|
|
102
102
|
matcher.from '1'
|
@@ -105,7 +105,7 @@ RSpec.describe Normalizy::RSpec::Matcher, '.matches?' do
|
|
105
105
|
expect(matcher.matches?(object)).to eq false
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
it do
|
109
109
|
matcher = described_class.new(:downcase_field)
|
110
110
|
|
111
111
|
matcher.from 'BOTELHO'
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: normalizy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Washington Botelho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -58,20 +58,6 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rubocop
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: rubocop-rspec
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
171
|
version: '0'
|
186
172
|
requirements: []
|
187
173
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.7.
|
174
|
+
rubygems_version: 2.7.7
|
189
175
|
signing_key:
|
190
176
|
specification_version: 4
|
191
177
|
summary: Attribute normalizer for ActiveRecord.
|