eac_rails_utils 0.13.5 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1529b1bebaa871484fb124ed0a9fc52a8bed38eb14419a61b4423392a33a60e
4
- data.tar.gz: ca06e07efcce2b7bd6689383a6daa2e2db6a299d20b6ab3aa73cdc8fbad5c364
3
+ metadata.gz: 5c4f6d085f9a7e1f6b39c4028498cac28f482540993e73bdadff0b58e6f1e214
4
+ data.tar.gz: d369558ea68714a4d0dedb89b3af900945be5c57113da0241b5332e818f634d8
5
5
  SHA512:
6
- metadata.gz: 6edd15a5b430f16fe7459e8d0a7aa445440b0349f3af6c6f045d8a555d8870519a2b008976d93806276b729227cf967079387eee1864a1903fc5465a3934edb6
7
- data.tar.gz: ac974c20369e17f6dfbe37b8ca1d6f3ddabe3b56494302cfc88beee67d4fa9cdb62faa9eed95d9adc1b680ac9c3d7d9e0379c44056bc9ea2dab76c6e07815a0a
6
+ metadata.gz: 591317f786a1edac276ac1ce0ecea5dcacbdfdbbd5635b51cd8e064c45ea921e4b8819bf78b49be0e708d13843843b896ab4e33d8f034e1146cb6584e0a9c798
7
+ data.tar.gz: 6f9760a2990de21e42b779f22d38aff09fa83b722959f551aff3bace7b9eef7f0db9cb8acb617bd3a5d4f9935e95090546c64de317cd8d68d4503b2d0e11989f
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ def patch_json?
4
+ require 'json'
5
+
6
+ ::Gem::Version.new(RUBY_VERSION) >= ::Gem::Version.new('2.7') &&
7
+ ::Gem::Version.new(JSON::VERSION) < ::Gem::Version.new('2')
8
+ rescue ::LoadError
9
+ false
10
+ end
11
+
12
+ if patch_json?
13
+ module JSON
14
+ module_function
15
+
16
+ def parse(source, opts = {})
17
+ Parser.new(source, **opts).parse
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRailsUtils
6
+ module Rspec
7
+ module Setup
8
+ module ModelsUtils
9
+ def model_record_attribute_test(record_variable, attribute, valid, value)
10
+ context("when #{record_variable}.#{attribute} == #{value}") do
11
+ before do
12
+ send(record_variable).send("#{attribute}=", value)
13
+ end
14
+
15
+ it "#{record_variable} should be {valid ? '' : 'not '}valid" do
16
+ expect(send(record_variable).valid?).to send("be_#{valid ? 'truthy' : 'falsy'}"),
17
+ send(record_variable).errors.messages
18
+ end
19
+ end
20
+ end
21
+
22
+ def model_record_values_attribute_test(record_variable, attribute, valid, values)
23
+ values.each do |value|
24
+ model_record_attribute_test(record_variable, attribute, valid, value)
25
+ end
26
+ end
27
+
28
+ def model_record_valid_invalid_values_attribute_test(record_variable, attribute,
29
+ valid_values, invalid_values)
30
+ {
31
+ false => invalid_values,
32
+ true => valid_values
33
+ }.each do |valid, values|
34
+ model_record_values_attribute_test(record_variable, attribute, valid, values)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRailsUtils
6
+ module Rspec
7
+ module Setup
8
+ require_sub __FILE__
9
+
10
+ def self.extended(setup_obj)
11
+ setup_obj.rspec_config.extend(::EacRailsUtils::Rspec::Setup::ModelsUtils)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsUtils
4
+ module Rspec
5
+ require 'eac_ruby_utils/require_sub'
6
+ ::EacRubyUtils.require_sub(__FILE__)
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.13.5'
4
+ VERSION = '0.14.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.5
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E.A.C.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel-associations
@@ -162,6 +162,7 @@ files:
162
162
  - app/validators/eac_rails_utils/cpf_validator.rb
163
163
  - app/validators/eac_rails_utils/no_presence_validator.rb
164
164
  - config/initializers/assets.rb
165
+ - config/initializers/json.rb
165
166
  - config/locales/en.yml
166
167
  - config/locales/pt-BR.yml
167
168
  - lib/assets/images/sort_asc.png
@@ -199,6 +200,9 @@ files:
199
200
  - lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
200
201
  - lib/eac_rails_utils/patches/rails_5_2.rb
201
202
  - lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
203
+ - lib/eac_rails_utils/rspec.rb
204
+ - lib/eac_rails_utils/rspec/setup.rb
205
+ - lib/eac_rails_utils/rspec/setup/models_utils.rb
202
206
  - lib/eac_rails_utils/version.rb
203
207
  homepage:
204
208
  licenses: []