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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c4f6d085f9a7e1f6b39c4028498cac28f482540993e73bdadff0b58e6f1e214
|
4
|
+
data.tar.gz: d369558ea68714a4d0dedb89b3af900945be5c57113da0241b5332e818f634d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
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: []
|