unidom-common-rspec 2.0 → 2.0.1
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: e73a57fee4cef81976cb6d387f8ee3b79c7f220533492971eed511233a545629
|
4
|
+
data.tar.gz: 9b1612de7e7f00f400326bec3b428fa870d52fd8c3eedd92272350f17236874e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22e69f347d5638e3022e20111643ab5bd3a97d6a6af7749a5b949ffbe7f916c8d9a5956309e746b0bd048e944557c7863e2739804727a3b30312dc5a98d2c740
|
7
|
+
data.tar.gz: 6c42f4595da343f446ba97eec954eed80d689cd109ee43d456516b56e2a815426fb42077835612ae2b4efdc74616fe672debdb319fcf60ca20f13bb8bde15da0
|
data/CHANGELOG.md
CHANGED
data/ROADMAP.md
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
shared_examples 'ActiveModel::EachValidator' do |valid_values, invalid_values|
|
2
2
|
|
3
3
|
mock_model_class_name = "#{described_class.name}MockModel"
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
if mock_model_class_name.deconstantize.present?
|
5
|
+
mock_model_namespace = mock_model_class_name.deconstantize.constantize
|
6
|
+
mock_model_name = mock_model_class_name.demodulize
|
7
|
+
else
|
8
|
+
mock_model_namespace = Object
|
9
|
+
mock_model_name = mock_model_class_name
|
10
|
+
end
|
11
|
+
|
7
12
|
mock_model_namespace.const_set mock_model_name, Class.new
|
8
|
-
class_instance
|
13
|
+
class_instance = mock_model_namespace.const_get mock_model_name
|
14
|
+
validator_name = described_class.to_s.underscore.chomp('_validator').to_sym
|
9
15
|
|
10
16
|
class_instance.class_eval do
|
11
17
|
include ActiveModel::Model
|
@@ -1,8 +1,8 @@
|
|
1
1
|
shared_examples 'validates numericality' do |model_attributes, attribute_name, options|
|
2
2
|
|
3
3
|
attribute_name = attribute_name.to_sym
|
4
|
-
presence_validator = described_class.validators.select { |v| v.is_a?(ActiveRecord::Validations::PresenceValidator)&&v.attributes.include?(attribute_name) }.first
|
5
|
-
excluded_validators = described_class.validators.select { |v| v.attributes.include?(attribute_name)&&![ ActiveRecord::Validations::PresenceValidator, ActiveModel::Validations::NumericalityValidator ].include?(v.class) }
|
4
|
+
presence_validator = described_class.validators.select { |v| (v.is_a?(ActiveModel::Validations::PresenceValidator)||v.is_a?(ActiveRecord::Validations::PresenceValidator))&&v.attributes.include?(attribute_name) }.first
|
5
|
+
excluded_validators = described_class.validators.select { |v| v.attributes.include?(attribute_name)&&![ ActiveRecord::Validations::PresenceValidator, ActiveRecord::Validations::NumericalityValidator, ActiveModel::Validations::PresenceValidator, ActiveModel::Validations::NumericalityValidator ].include?(v.class) }
|
6
6
|
|
7
7
|
if excluded_validators.present?
|
8
8
|
raise ArgumentError.new("The validators on the #{attribute_name.inspect} attribute must be PresenceValidator or NumericalityValidator. The excluded validator#{excluded_validators.size>1 ? 's are' : ' is'}: #{excluded_validators.inspect}.")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-common-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|