shoulda-matchers 6.0.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +18 -9
- data/lib/shoulda/matchers/action_controller/permit_matcher.rb +6 -8
- data/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +13 -15
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +37 -1
- data/lib/shoulda/matchers/active_model/comparison_matcher.rb +1 -6
- data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +7 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb +0 -5
- data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +0 -6
- data/lib/shoulda/matchers/active_model/validate_comparison_of_matcher.rb +11 -13
- data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +20 -8
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +9 -11
- data/lib/shoulda/matchers/active_model/validation_matcher/build_description.rb +6 -7
- data/lib/shoulda/matchers/active_record/association_matcher.rb +543 -15
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +9 -1
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -0
- data/lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb +4 -0
- data/lib/shoulda/matchers/active_record/association_matchers/optional_matcher.rb +23 -19
- data/lib/shoulda/matchers/active_record/association_matchers/required_matcher.rb +27 -23
- data/lib/shoulda/matchers/active_record/encrypt_matcher.rb +174 -0
- data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +10 -10
- data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_record/normalize_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_record/uniqueness/model.rb +1 -1
- data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +82 -70
- data/lib/shoulda/matchers/active_record.rb +1 -0
- data/lib/shoulda/matchers/doublespeak/double_collection.rb +2 -6
- data/lib/shoulda/matchers/doublespeak/world.rb +2 -6
- data/lib/shoulda/matchers/independent/delegate_method_matcher.rb +12 -14
- data/lib/shoulda/matchers/integrations/libraries/action_controller.rb +7 -5
- data/lib/shoulda/matchers/integrations/libraries/routing.rb +5 -3
- data/lib/shoulda/matchers/util.rb +17 -19
- data/lib/shoulda/matchers/version.rb +1 -1
- metadata +4 -3
@@ -440,22 +440,20 @@ module Shoulda
|
|
440
440
|
end
|
441
441
|
|
442
442
|
def formatted_calls_on_delegate_object
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
443
|
+
String.new.tap do |string|
|
444
|
+
if calls_on_delegate_object.any?
|
445
|
+
string << "\n\n"
|
446
|
+
calls_on_delegate_object.each_with_index do |call, i|
|
447
|
+
name = call.method_name
|
448
|
+
args = call.args.map(&:inspect).join(', ')
|
449
|
+
string << "#{i + 1}) #{name}(#{args})\n"
|
450
|
+
end
|
451
|
+
else
|
452
|
+
string << ' (none)'
|
451
453
|
end
|
452
|
-
else
|
453
|
-
string << ' (none)'
|
454
|
-
end
|
455
454
|
|
456
|
-
|
457
|
-
|
458
|
-
string
|
455
|
+
string.rstrip!
|
456
|
+
end
|
459
457
|
end
|
460
458
|
end
|
461
459
|
end
|
@@ -12,15 +12,17 @@ module Shoulda
|
|
12
12
|
def integrate_with(test_framework)
|
13
13
|
test_framework.include(matchers_module, type: :controller)
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
tap do |instance|
|
16
|
+
ActiveSupport.on_load(:action_controller_test_case, run_once: true) do
|
17
|
+
instance.include_into(::ActionController::TestCase, instance.matchers_module) do
|
18
|
+
def subject # rubocop:disable Lint/NestedMethodDefinition
|
19
|
+
@controller
|
20
|
+
end
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
22
|
-
private
|
23
|
-
|
24
26
|
def matchers_module
|
25
27
|
Shoulda::Matchers::ActionController
|
26
28
|
end
|
@@ -12,11 +12,13 @@ module Shoulda
|
|
12
12
|
def integrate_with(test_framework)
|
13
13
|
test_framework.include(matchers_module, type: :routing)
|
14
14
|
|
15
|
-
|
15
|
+
tap do |instance|
|
16
|
+
ActiveSupport.on_load(:action_controller_test_case, run_once: true) do
|
17
|
+
instance.include_into(::ActionController::TestCase, instance.matchers_module)
|
18
|
+
end
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
|
-
private
|
19
|
-
|
20
22
|
def matchers_module
|
21
23
|
Shoulda::Matchers::Routing
|
22
24
|
end
|
@@ -7,10 +7,9 @@ module Shoulda
|
|
7
7
|
MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY = 500
|
8
8
|
|
9
9
|
def self.deconstantize(path)
|
10
|
-
if (
|
11
|
-
|
12
|
-
|
13
|
-
)
|
10
|
+
if defined?(ActiveSupport::Inflector) &&
|
11
|
+
ActiveSupport::Inflector.respond_to?(:deconstantize)
|
12
|
+
|
14
13
|
ActiveSupport::Inflector.deconstantize(path)
|
15
14
|
else
|
16
15
|
path.to_s[0...(path.to_s.rindex('::') || 0)]
|
@@ -18,10 +17,9 @@ module Shoulda
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def self.safe_constantize(camel_cased_word)
|
21
|
-
if (
|
22
|
-
|
23
|
-
|
24
|
-
)
|
20
|
+
if defined?(ActiveSupport::Inflector) &&
|
21
|
+
ActiveSupport::Inflector.respond_to?(:safe_constantize)
|
22
|
+
|
25
23
|
ActiveSupport::Inflector.safe_constantize(camel_cased_word)
|
26
24
|
else
|
27
25
|
begin
|
@@ -68,21 +66,21 @@ module Shoulda
|
|
68
66
|
end
|
69
67
|
|
70
68
|
def self.inspect_range(range)
|
71
|
-
"#{inspect_value(range.
|
69
|
+
"#{inspect_value(range.begin)} to #{inspect_value(range.end)}"
|
72
70
|
end
|
73
71
|
|
74
72
|
def self.inspect_hash(hash)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}.join(', ')
|
73
|
+
String.new('‹{').tap do |output|
|
74
|
+
output << hash.map { |key, value|
|
75
|
+
if key.is_a?(Symbol)
|
76
|
+
"#{key}: #{value.inspect}"
|
77
|
+
else
|
78
|
+
"#{key.inspect} => #{value.inspect}"
|
79
|
+
end
|
80
|
+
}.join(', ')
|
84
81
|
|
85
|
-
|
82
|
+
output << '}›'
|
83
|
+
end
|
86
84
|
end
|
87
85
|
|
88
86
|
def self.dummy_value_for(column_type, array: false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tammer Saleh
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date:
|
17
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activesupport
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
|
117
117
|
- lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb
|
118
118
|
- lib/shoulda/matchers/active_record/define_enum_for_matcher.rb
|
119
|
+
- lib/shoulda/matchers/active_record/encrypt_matcher.rb
|
119
120
|
- lib/shoulda/matchers/active_record/have_attached_matcher.rb
|
120
121
|
- lib/shoulda/matchers/active_record/have_db_column_matcher.rb
|
121
122
|
- lib/shoulda/matchers/active_record/have_db_index_matcher.rb
|
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
198
|
- !ruby/object:Gem::Version
|
198
199
|
version: '0'
|
199
200
|
requirements: []
|
200
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.5.6
|
201
202
|
signing_key:
|
202
203
|
specification_version: 4
|
203
204
|
summary: Simple one-liner tests for common Rails functionality
|