normalizy 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -28
  3. data/README.md +22 -16
  4. data/lib/normalizy/filters/money.rb +2 -2
  5. data/lib/normalizy/filters/percent.rb +2 -2
  6. data/lib/normalizy/version.rb +1 -1
  7. metadata +27 -94
  8. data/spec/normalizy/config/add_spec.rb +0 -21
  9. data/spec/normalizy/config/alias_spec.rb +0 -29
  10. data/spec/normalizy/config/default_filters_spec.rb +0 -19
  11. data/spec/normalizy/config/initialize_spec.rb +0 -16
  12. data/spec/normalizy/config/normalizy_aliases_spec.rb +0 -9
  13. data/spec/normalizy/extensions/filters/date_spec.rb +0 -23
  14. data/spec/normalizy/extensions/filters/money_spec.rb +0 -38
  15. data/spec/normalizy/extensions/filters/number_spec.rb +0 -9
  16. data/spec/normalizy/extensions/filters/percent_spec.rb +0 -30
  17. data/spec/normalizy/extensions/filters/slug_spec.rb +0 -14
  18. data/spec/normalizy/extensions/filters/strip_spec.rb +0 -21
  19. data/spec/normalizy/extensions/model_spec.rb +0 -107
  20. data/spec/normalizy/extensions/normalizy_rules_spec.rb +0 -198
  21. data/spec/normalizy/filters/date_spec.rb +0 -72
  22. data/spec/normalizy/filters/money_spec.rb +0 -282
  23. data/spec/normalizy/filters/number_spec.rb +0 -33
  24. data/spec/normalizy/filters/percent_spec.rb +0 -168
  25. data/spec/normalizy/filters/slug_spec.rb +0 -24
  26. data/spec/normalizy/filters/strip_spec.rb +0 -13
  27. data/spec/normalizy/normalizy/configure_spec.rb +0 -11
  28. data/spec/normalizy/rspec/matcher/description_spec.rb +0 -27
  29. data/spec/normalizy/rspec/matcher/failure_message_spec.rb +0 -48
  30. data/spec/normalizy/rspec/matcher/failure_message_when_negated_spec.rb +0 -30
  31. data/spec/normalizy/rspec/matcher/from_spec.rb +0 -19
  32. data/spec/normalizy/rspec/matcher/matches_spec.rb +0 -117
  33. data/spec/normalizy/rspec/matcher/to_spec.rb +0 -19
  34. data/spec/rails_helper.rb +0 -9
  35. data/spec/support/common.rb +0 -11
  36. data/spec/support/db/schema.rb +0 -83
  37. data/spec/support/filters/blacklist.rb +0 -11
  38. data/spec/support/filters/block.rb +0 -11
  39. data/spec/support/filters/info.rb +0 -11
  40. data/spec/support/models/alias.rb +0 -7
  41. data/spec/support/models/match.rb +0 -9
  42. data/spec/support/models/model.rb +0 -28
  43. data/spec/support/models/model_date.rb +0 -9
  44. data/spec/support/models/model_money.rb +0 -10
  45. data/spec/support/models/model_number.rb +0 -5
  46. data/spec/support/models/model_percent.rb +0 -10
  47. data/spec/support/models/model_slug.rb +0 -6
  48. data/spec/support/models/model_strip.rb +0 -8
  49. data/spec/support/models/rule.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 328bb0456c2b8619b62dd267f391e8c5a89091d90d77ae201492f0b3033251ca
4
- data.tar.gz: 77702f7ae3b66ddc7fc80cd35356d7ce4b16dc364459ba112f7b997771bba23e
3
+ metadata.gz: 0ce6511269094da3b936369b12195ad147ecbc4a67be1649eedf4a96a18aba63
4
+ data.tar.gz: bc8454295d05564e66a702d528132487297a0b969a62b56a182cc33e27156747
5
5
  SHA512:
6
- metadata.gz: 0250c84197262d472c2f0f5b951a2deb09bc31a30832269b620bca1c6703e5d32f68db6e5cd85921bd4bd135f3c3bc03224da9db42df6d4d90b601214461d0d3
7
- data.tar.gz: 92f6b33d5d677fafcc38984488758f99411e9a6386a90fe236b58d90b9c3a6b45c2e7701ac04a9af4c80195c83cfd9eb8bb231f830fc022d079fc1b0b87d9250
6
+ metadata.gz: 197c6dc140be871e4758e67e8197ab55015760ec711c54f9923783bd516d79d084a8d13fe39fd6ff582cf634796b533938adfc7d437257d4f8a96ee02f926f5e
7
+ data.tar.gz: 36b8f76aa291b2bd977902777518e8c48ca4a6f7be5ab224d17e3de33c04cd1d02fdca9387dcf7ffeab83fc08ebc2f2e657a99fccaa169d6713cad67d236ea46
data/CHANGELOG.md CHANGED
@@ -1,60 +1,85 @@
1
+ ## v1.6.0
2
+
3
+ ### Fixes
4
+
5
+ - Fix Money Filter to use the correct default Rails path for Currency and Percentage;
6
+
7
+ ### Updates
8
+
9
+ - Adds Code Quality;
10
+ - Adds Test Coverage;
11
+ - Migrates the build to Github Actions;
12
+ - Removes Git dependency for build;
13
+
1
14
  ## v1.5.0
2
15
 
3
- - Features:
4
- - Filter `date` now supports call object that respond to `beginning_of_day` or `end_of_day`;
16
+ ### Features
17
+
18
+ - Filter `date` now supports call object that respond to `beginning_of_day` or `end_of_day`;
5
19
 
6
20
  ## v1.4.0
7
21
 
8
- - Features:
9
- - Adds `date` support for `Date` class.
22
+ ### Features
23
+
24
+ - Adds `date` support for `Date` class.
10
25
 
11
26
  ## v1.3.0
12
27
 
13
- - Changes:
14
- - Support Rails 6.
28
+ ### Updates
29
+
30
+ - Support Rails 6.
15
31
 
16
32
  ## v1.2.0
17
33
 
18
- - Features:
19
- - `money` filter now allows negative numbers.
34
+ ### Features
35
+
36
+ - `money` filter now allows negative numbers.
20
37
 
21
38
  ## v1.1.1
22
39
 
23
- - Fixes:
24
- - When use `slug` filter the original values was not saved.
40
+ ### Fixes
41
+
42
+ - When use `slug` filter the original values was not saved.
25
43
 
26
44
  ## v1.1.0
27
45
 
28
- - Features:
29
- - Added `slug` filter with option to apply the value on other field.
46
+ ### Features
47
+
48
+ - Added `slug` filter with option to apply the value on other field.
30
49
 
31
50
  ## v1.0.1
32
51
 
33
- - Fixes:
34
- - When `type` options was `cents` and had no decimal on number, extra decimal were added.
52
+ ### Fixes
53
+
54
+ - When `type` options was `cents` and had no decimal on number, extra decimal were added.
35
55
 
36
56
  ## v1.0.0
37
57
 
38
- - Changes:
39
- - `raw` options was dropped since `prepend` already works before type cast;
40
- - Multiple lines of `normalizy` will be evaluated from the bottom to top.
58
+ ### Updates
59
+
60
+ - `raw` options was dropped since `prepend` already works before type cast;
61
+ - Multiple lines of `normalizy` will be evaluated from the bottom to top.
41
62
 
42
- - Features:
43
- - `alias` configuration now accepts options;
63
+ ### Features
44
64
 
45
- - Fixes:
46
- - Multiple filters were not running together.
65
+ - `alias` configuration now accepts options;
66
+
67
+ ### Fixes
68
+
69
+ - Multiple filters were not running together.
47
70
 
48
71
  ## v0.2.0
49
72
 
50
- - Changes:
51
- - `number` filter no more make cast automatically.
52
- - `number` now accept `cast` options with method to be used on cast type;
73
+ ### Updates
74
+
75
+ - `number` filter no more make cast automatically.
76
+ - `number` now accept `cast` options with method to be used on cast type;
77
+
78
+ ### Features
53
79
 
54
- - Features:
55
- - add `date` filter with `format`, `time_zone` and I18n error message support;
56
- - add `money` filter with `cast`, `type` and I18n support;
57
- - add `percent` filter with `cast`, `type` and I18n support.
80
+ - add `date` filter with `format`, `time_zone` and I18n error message support;
81
+ - add `money` filter with `cast`, `type` and I18n support;
82
+ - add `percent` filter with `cast`, `type` and I18n support.
58
83
 
59
84
  ## v0.1.0
60
85
 
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Normalizy
2
2
 
3
- [![Build Status](https://travis-ci.org/wbotelhos/normalizy.svg)](https://travis-ci.org/wbotelhos/normalizy)
3
+ [![CI](https://github.com/wbotelhos/normalizy/workflows/CI/badge.svg)](https://github.com/wbotelhos/normalizy/actions)
4
4
  [![Gem Version](https://badge.fury.io/rb/normalizy.svg)](https://badge.fury.io/rb/normalizy)
5
- [![Patreon](https://img.shields.io/badge/donate-%3C3-brightgreen.svg)](https://www.patreon.com/wbotelhos)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/f312587b4f126bb13e85/maintainability)](https://codeclimate.com/github/wbotelhos/normalizy/maintainability)
6
+ [![Coverage](https://codecov.io/gh/wbotelhos/normalizy/branch/main/graph/badge.svg)](https://codecov.io/gh/wbotelhos/normalizy)
7
+ [![Sponsor](https://img.shields.io/badge/sponsor-%3C3-green)](https://www.patreon.com/wbotelhos)
6
8
 
7
- Attribute normalizer for ActiveRecord.
9
+ Attribute normalizer for Rails.
8
10
 
9
11
  ## Description
10
12
 
@@ -140,9 +142,10 @@ If you do not want pass it as options, Normalizy will fetch your I18n config:
140
142
 
141
143
  ```yaml
142
144
  en:
143
- currency:
144
- format:
145
- separator: '.'
145
+ number:
146
+ currency:
147
+ format:
148
+ separator: '.'
146
149
  ```
147
150
 
148
151
  And if it does not exists, `.` will be used as default.
@@ -190,9 +193,10 @@ If you do not want pass it as options, Normalizy will fetch your I18n config:
190
193
 
191
194
  ```yaml
192
195
  en:
193
- currency:
194
- format:
195
- separator: 2
196
+ number:
197
+ currency:
198
+ format:
199
+ precision: 2
196
200
  ```
197
201
 
198
202
  And if it does not exists, `2` will be used as default.
@@ -265,9 +269,10 @@ If you do not want pass it as options, Normalizy will fetch your I18n config:
265
269
 
266
270
  ```yaml
267
271
  en:
268
- percentage:
269
- format:
270
- separator: '.'
272
+ number:
273
+ percentage:
274
+ format:
275
+ separator: '.'
271
276
  ```
272
277
 
273
278
  And if it does not exists, `.` will be used as default.
@@ -315,9 +320,10 @@ If you do not want pass it as options, Normalizy will fetch your I18n config:
315
320
 
316
321
  ```yaml
317
322
  en:
318
- percentage:
319
- format:
320
- separator: 2
323
+ number:
324
+ percentage:
325
+ format:
326
+ separator: 2
321
327
  ```
322
328
 
323
329
  And if it does not exists, `2` will be used as default.
@@ -449,7 +455,7 @@ Now, all normalization will include `squish`, even when no rule is declared.
449
455
 
450
456
  ```ruby
451
457
  normalizy :name
452
- ' Washington Botelho '
458
+ " Washington \n Botelho "
453
459
  # 'Washington Botelho'
454
460
  ```
455
461
 
@@ -29,7 +29,7 @@ module Normalizy
29
29
  end
30
30
 
31
31
  def precision(options)
32
- options.fetch :precision, I18n.t('currency.format.precision', default: 2)
32
+ options.fetch(:precision, I18n.t('number.currency.format.precision', default: 2))
33
33
  end
34
34
 
35
35
  def precisioned(value, options)
@@ -37,7 +37,7 @@ module Normalizy
37
37
  end
38
38
 
39
39
  def separator(options)
40
- options.fetch :separator, I18n.t('currency.format.separator', default: '.')
40
+ options.fetch(:separator, I18n.t('number.currency.format.separator', default: '.'))
41
41
  end
42
42
  end
43
43
  end
@@ -29,7 +29,7 @@ module Normalizy
29
29
  end
30
30
 
31
31
  def precision(options)
32
- options.fetch :precision, I18n.t('percentage.format.precision', default: 2)
32
+ options.fetch(:precision, I18n.t('number.percentage.format.precision', default: 2))
33
33
  end
34
34
 
35
35
  def precisioned(value, options)
@@ -37,7 +37,7 @@ module Normalizy
37
37
  end
38
38
 
39
39
  def separator(options)
40
- options.fetch :separator, I18n.t('percentage.format.separator', default: '.')
40
+ options.fetch(:separator, I18n.t('number.percentage.format.separator', default: '.'))
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Normalizy
4
- VERSION = '1.5.0'
4
+ VERSION = '1.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalizy
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
  - Washington Botelho
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-30 00:00:00.000000000 Z
11
+ date: 2022-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pry-byebug
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,11 +122,14 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
- description: Attribute normalizer for ActiveRecord.
125
+ description: Attribute normalizer for Rails.
112
126
  email: wbotelhos@gmail.com
113
127
  executables: []
114
128
  extensions: []
115
- extra_rdoc_files: []
129
+ extra_rdoc_files:
130
+ - CHANGELOG.md
131
+ - LICENSE
132
+ - README.md
116
133
  files:
117
134
  - CHANGELOG.md
118
135
  - LICENSE
@@ -131,53 +148,11 @@ files:
131
148
  - lib/normalizy/filters/strip.rb
132
149
  - lib/normalizy/rspec/matcher.rb
133
150
  - lib/normalizy/version.rb
134
- - spec/normalizy/config/add_spec.rb
135
- - spec/normalizy/config/alias_spec.rb
136
- - spec/normalizy/config/default_filters_spec.rb
137
- - spec/normalizy/config/initialize_spec.rb
138
- - spec/normalizy/config/normalizy_aliases_spec.rb
139
- - spec/normalizy/extensions/filters/date_spec.rb
140
- - spec/normalizy/extensions/filters/money_spec.rb
141
- - spec/normalizy/extensions/filters/number_spec.rb
142
- - spec/normalizy/extensions/filters/percent_spec.rb
143
- - spec/normalizy/extensions/filters/slug_spec.rb
144
- - spec/normalizy/extensions/filters/strip_spec.rb
145
- - spec/normalizy/extensions/model_spec.rb
146
- - spec/normalizy/extensions/normalizy_rules_spec.rb
147
- - spec/normalizy/filters/date_spec.rb
148
- - spec/normalizy/filters/money_spec.rb
149
- - spec/normalizy/filters/number_spec.rb
150
- - spec/normalizy/filters/percent_spec.rb
151
- - spec/normalizy/filters/slug_spec.rb
152
- - spec/normalizy/filters/strip_spec.rb
153
- - spec/normalizy/normalizy/configure_spec.rb
154
- - spec/normalizy/rspec/matcher/description_spec.rb
155
- - spec/normalizy/rspec/matcher/failure_message_spec.rb
156
- - spec/normalizy/rspec/matcher/failure_message_when_negated_spec.rb
157
- - spec/normalizy/rspec/matcher/from_spec.rb
158
- - spec/normalizy/rspec/matcher/matches_spec.rb
159
- - spec/normalizy/rspec/matcher/to_spec.rb
160
- - spec/rails_helper.rb
161
- - spec/support/common.rb
162
- - spec/support/db/schema.rb
163
- - spec/support/filters/blacklist.rb
164
- - spec/support/filters/block.rb
165
- - spec/support/filters/info.rb
166
- - spec/support/models/alias.rb
167
- - spec/support/models/match.rb
168
- - spec/support/models/model.rb
169
- - spec/support/models/model_date.rb
170
- - spec/support/models/model_money.rb
171
- - spec/support/models/model_number.rb
172
- - spec/support/models/model_percent.rb
173
- - spec/support/models/model_slug.rb
174
- - spec/support/models/model_strip.rb
175
- - spec/support/models/rule.rb
176
151
  homepage: https://github.com/wbotelhos/normalizy
177
152
  licenses:
178
153
  - MIT
179
154
  metadata: {}
180
- post_install_message:
155
+ post_install_message:
181
156
  rdoc_options: []
182
157
  require_paths:
183
158
  - lib
@@ -192,50 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
167
  - !ruby/object:Gem::Version
193
168
  version: '0'
194
169
  requirements: []
195
- rubygems_version: 3.1.2
196
- signing_key:
170
+ rubygems_version: 3.2.22
171
+ signing_key:
197
172
  specification_version: 4
198
- summary: Attribute normalizer for ActiveRecord.
199
- test_files:
200
- - spec/normalizy/filters/date_spec.rb
201
- - spec/normalizy/filters/number_spec.rb
202
- - spec/normalizy/filters/money_spec.rb
203
- - spec/normalizy/filters/percent_spec.rb
204
- - spec/normalizy/filters/slug_spec.rb
205
- - spec/normalizy/filters/strip_spec.rb
206
- - spec/normalizy/config/initialize_spec.rb
207
- - spec/normalizy/config/normalizy_aliases_spec.rb
208
- - spec/normalizy/config/alias_spec.rb
209
- - spec/normalizy/config/add_spec.rb
210
- - spec/normalizy/config/default_filters_spec.rb
211
- - spec/normalizy/extensions/filters/date_spec.rb
212
- - spec/normalizy/extensions/filters/number_spec.rb
213
- - spec/normalizy/extensions/filters/money_spec.rb
214
- - spec/normalizy/extensions/filters/percent_spec.rb
215
- - spec/normalizy/extensions/filters/slug_spec.rb
216
- - spec/normalizy/extensions/filters/strip_spec.rb
217
- - spec/normalizy/extensions/normalizy_rules_spec.rb
218
- - spec/normalizy/extensions/model_spec.rb
219
- - spec/normalizy/normalizy/configure_spec.rb
220
- - spec/normalizy/rspec/matcher/matches_spec.rb
221
- - spec/normalizy/rspec/matcher/failure_message_spec.rb
222
- - spec/normalizy/rspec/matcher/failure_message_when_negated_spec.rb
223
- - spec/normalizy/rspec/matcher/to_spec.rb
224
- - spec/normalizy/rspec/matcher/from_spec.rb
225
- - spec/normalizy/rspec/matcher/description_spec.rb
226
- - spec/support/filters/block.rb
227
- - spec/support/filters/blacklist.rb
228
- - spec/support/filters/info.rb
229
- - spec/support/models/model_money.rb
230
- - spec/support/models/match.rb
231
- - spec/support/models/model_date.rb
232
- - spec/support/models/model.rb
233
- - spec/support/models/model_slug.rb
234
- - spec/support/models/rule.rb
235
- - spec/support/models/model_percent.rb
236
- - spec/support/models/model_number.rb
237
- - spec/support/models/model_strip.rb
238
- - spec/support/models/alias.rb
239
- - spec/support/common.rb
240
- - spec/support/db/schema.rb
241
- - spec/rails_helper.rb
173
+ summary: Attribute normalizer for Rails.
174
+ test_files: []
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe Normalizy::Config, '#add' do
6
- it 'adds filters to the built-in filters' do
7
- Normalizy.configure do |config|
8
- config.add :blacklist, :blacklist_filter
9
- end
10
-
11
- expect(Normalizy.config.filters).to eq(
12
- blacklist: :blacklist_filter,
13
- date: Normalizy::Filters::Date,
14
- money: Normalizy::Filters::Money,
15
- number: Normalizy::Filters::Number,
16
- percent: Normalizy::Filters::Percent,
17
- slug: Normalizy::Filters::Slug,
18
- strip: Normalizy::Filters::Strip
19
- )
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe Normalizy::Config, '#alias' do
6
- it 'accepts alias' do
7
- Normalizy.configure do |config|
8
- config.alias :email, :downcase
9
- end
10
-
11
- expect(Alias.create(email: 'Botelho').email).to eq 'botelho'
12
- end
13
-
14
- it 'accepts alias with options' do
15
- Normalizy.configure do |config|
16
- config.alias :with_arg, strip: { side: :left }
17
- end
18
-
19
- expect(Alias.create(with_arg_field: ' trim').with_arg_field).to eq 'trim'
20
- end
21
-
22
- it 'accepts late options' do
23
- Normalizy.configure do |config|
24
- config.alias :with_inline_arg, :strip
25
- end
26
-
27
- expect(Alias.create(with_inline_arg_field: ' trim').with_inline_arg_field).to eq 'trim'
28
- end
29
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe Normalizy::Config, 'default_filters' do
6
- context 'when get' do
7
- it 'returns the default filters' do
8
- expect(subject.default_filters).to eq({})
9
- end
10
- end
11
-
12
- context 'when set' do
13
- before { subject.default_filters = :blank }
14
-
15
- it 'keeps the original' do
16
- expect(subject.default_filters).to eq :blank
17
- end
18
- end
19
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe Normalizy::Config, 'filters' do
6
- it 'loads some filters' do
7
- expect(subject.filters).to eq(
8
- date: Normalizy::Filters::Date,
9
- money: Normalizy::Filters::Money,
10
- number: Normalizy::Filters::Number,
11
- percent: Normalizy::Filters::Percent,
12
- slug: Normalizy::Filters::Slug,
13
- strip: Normalizy::Filters::Strip
14
- )
15
- end
16
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe Normalizy::Config, 'normalizy_aliases' do
6
- it 'has the right defaults' do
7
- expect(subject.normalizy_aliases).to eq({})
8
- end
9
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe ModelDate, 'filters:date' do
6
- it { expect(described_class.create(date: '1984-10-23').date).to eq(Time.new(1984, 10, 23, 0, 0, 0, 0)) }
7
- it { expect(described_class.create(date_format: '84/10/23').date_format).to eq(Time.new(1984, 10, 23, 0, 0, 0, 0)) }
8
-
9
- it do
10
- hours = ActiveSupport::TimeZone['Brasilia'].utc_offset / 3600.0
11
- expected = Time.new(1984, 10, 23, 0, 0, 0, 0) + (hours.hours * -1)
12
-
13
- expect(described_class.create(date_time_zone: '1984-10-23').date_time_zone).to eq expected
14
- end
15
-
16
- it 'normalizys end date' do
17
- expect(described_class.new(date_time_end: Date.new(1984)).date_time_end).to eq(Time.new(1984).end_of_day)
18
- end
19
-
20
- it 'normalizys begin date' do
21
- expect(described_class.new(date_time_begin: Date.new(1984, 10, 23)).date_time_begin).to eq(Time.new(1984, 10, 23))
22
- end
23
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe ModelMoney, 'filters:money' do
6
- it do
7
- expect(described_class.create(text: '$ 42.00').text).to eq '42.00'
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'
12
- end
13
-
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'
17
- end
18
-
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
22
- end
23
-
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
27
- end
28
-
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
32
- end
33
-
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
37
- end
38
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe ModelNumber, 'filters:number' do
6
- it do
7
- expect(described_class.create(number: 'Botelho 32').number).to eq '32'
8
- end
9
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe ModelPercent, 'filters:percent' do
6
- it do
7
- expect(described_class.create(text: '42.00 %').text).to eq '42.00'
8
- expect(described_class.create(text: '42.10 %').text).to eq '42.10'
9
- end
10
-
11
- it do
12
- expect(described_class.create(cents_type: '42.33 %').cents_type).to eq '4233'
13
- end
14
-
15
- it do
16
- expect(described_class.create(cast_to_i: '42.00 %').cast_to_i).to be 42
17
- end
18
-
19
- it do
20
- expect(described_class.create(cast_to_d: '1.23 %').cast_to_d).to eq 1.23
21
- end
22
-
23
- it do
24
- expect(described_class.create(cents_type_and_cast_to_f: '42.00 %').cents_type_and_cast_to_f).to eq 4200.0
25
- end
26
-
27
- it do
28
- expect(described_class.create(cents_type_and_cast_to_i: '42.00 %').cents_type_and_cast_to_i).to eq 4200
29
- end
30
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe ModelSlug, 'filters:slug' do
6
- from = 'The Títle'
7
- to = 'the-title'
8
-
9
- it { expect(described_class.create(permalink: from).permalink).to eq to }
10
-
11
- it { expect(described_class.create(title: from).slug).to eq to }
12
-
13
- it { expect(described_class.create(title: from).title).to eq from }
14
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe ModelStrip, 'filters:strip' do
6
- it do
7
- expect(described_class.create(strip: ' Botelho ').strip).to eq 'Botelho'
8
- end
9
-
10
- it do
11
- expect(described_class.create(strip_side_left: ' Botelho ').strip_side_left).to eq 'Botelho '
12
- end
13
-
14
- it do
15
- expect(described_class.create(strip_side_right: ' Botelho ').strip_side_right).to eq ' Botelho'
16
- end
17
-
18
- it do
19
- expect(described_class.create(strip_side_both: ' Botelho ').strip_side_both).to eq 'Botelho'
20
- end
21
- end