shoulda-matchers 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +157 -77
- data/lib/shoulda/matchers.rb +13 -12
- data/lib/shoulda/matchers/action_controller.rb +13 -13
- data/lib/shoulda/matchers/active_model.rb +15 -26
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +9 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers.rb +5 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +5 -1
- data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +2 -21
- data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +27 -3
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +32 -0
- data/lib/shoulda/matchers/active_model/validation_matcher.rb +27 -0
- data/lib/shoulda/matchers/active_record.rb +13 -23
- data/lib/shoulda/matchers/active_record/association_matcher.rb +20 -4
- data/lib/shoulda/matchers/active_record/association_matchers.rb +12 -0
- data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +2 -2
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +12 -6
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +20 -3
- data/lib/shoulda/matchers/active_record/have_attached_matcher.rb +147 -0
- data/lib/shoulda/matchers/active_record/have_implicit_order_column.rb +106 -0
- data/lib/shoulda/matchers/active_record/have_secure_token_matcher.rb +28 -9
- data/lib/shoulda/matchers/active_record/uniqueness.rb +5 -5
- data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +2 -2
- data/lib/shoulda/matchers/doublespeak.rb +8 -7
- data/lib/shoulda/matchers/independent.rb +0 -2
- data/lib/shoulda/matchers/independent/delegate_method_matcher.rb +3 -0
- data/lib/shoulda/matchers/integrations.rb +6 -6
- data/lib/shoulda/matchers/integrations/test_frameworks.rb +4 -2
- data/lib/shoulda/matchers/rails_shim.rb +4 -0
- data/lib/shoulda/matchers/util.rb +9 -4
- data/lib/shoulda/matchers/util/word_wrap.rb +1 -1
- data/lib/shoulda/matchers/version.rb +1 -1
- metadata +8 -8
- data/MIT-LICENSE +0 -22
- data/lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb +0 -37
@@ -4,6 +4,14 @@ module Shoulda
|
|
4
4
|
module Matchers
|
5
5
|
# @private
|
6
6
|
module Doublespeak
|
7
|
+
autoload :Double, 'shoulda/matchers/doublespeak/double'
|
8
|
+
autoload :DoubleCollection, 'shoulda/matchers/doublespeak/double_collection'
|
9
|
+
autoload :DoubleImplementationRegistry, 'shoulda/matchers/doublespeak/double_implementation_registry'
|
10
|
+
autoload :MethodCall, 'shoulda/matchers/doublespeak/method_call'
|
11
|
+
autoload :ObjectDouble, 'shoulda/matchers/doublespeak/object_double'
|
12
|
+
autoload :ProxyImplementation, 'shoulda/matchers/doublespeak/proxy_implementation'
|
13
|
+
autoload :World, 'shoulda/matchers/doublespeak/world'
|
14
|
+
|
7
15
|
class << self
|
8
16
|
extend Forwardable
|
9
17
|
|
@@ -28,11 +36,4 @@ module Shoulda
|
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
31
|
-
require 'shoulda/matchers/doublespeak/double'
|
32
|
-
require 'shoulda/matchers/doublespeak/double_collection'
|
33
|
-
require 'shoulda/matchers/doublespeak/double_implementation_registry'
|
34
|
-
require 'shoulda/matchers/doublespeak/method_call'
|
35
|
-
require 'shoulda/matchers/doublespeak/object_double'
|
36
|
-
require 'shoulda/matchers/doublespeak/proxy_implementation'
|
37
39
|
require 'shoulda/matchers/doublespeak/stub_implementation'
|
38
|
-
require 'shoulda/matchers/doublespeak/world'
|
@@ -176,6 +176,9 @@ module Shoulda
|
|
176
176
|
|
177
177
|
# @private
|
178
178
|
class DelegateMethodMatcher
|
179
|
+
autoload :StubbedTarget, 'shoulda/matchers/independent/delegate_method_matcher/stubbed_target'
|
180
|
+
autoload :DelegateObjectNotSpecified, 'shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error'
|
181
|
+
|
179
182
|
def initialize(delegating_method)
|
180
183
|
@delegating_method = delegating_method
|
181
184
|
|
@@ -2,6 +2,12 @@ module Shoulda
|
|
2
2
|
module Matchers
|
3
3
|
# @private
|
4
4
|
module Integrations
|
5
|
+
autoload :Configuration, 'shoulda/matchers/integrations/configuration'
|
6
|
+
autoload :ConfigurationError, 'shoulda/matchers/integrations/configuration_error'
|
7
|
+
autoload :Inclusion, 'shoulda/matchers/integrations/inclusion'
|
8
|
+
autoload :Rails, 'shoulda/matchers/integrations/rails'
|
9
|
+
autoload :Registry, 'shoulda/matchers/integrations/registry'
|
10
|
+
|
5
11
|
class << self
|
6
12
|
def register_library(klass, name)
|
7
13
|
library_registry.register(klass, name)
|
@@ -33,11 +39,5 @@ module Shoulda
|
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
36
|
-
require 'shoulda/matchers/integrations/configuration'
|
37
|
-
require 'shoulda/matchers/integrations/configuration_error'
|
38
|
-
require 'shoulda/matchers/integrations/inclusion'
|
39
|
-
require 'shoulda/matchers/integrations/rails'
|
40
|
-
require 'shoulda/matchers/integrations/registry'
|
41
|
-
|
42
42
|
require 'shoulda/matchers/integrations/libraries'
|
43
43
|
require 'shoulda/matchers/integrations/test_frameworks'
|
@@ -1,15 +1,17 @@
|
|
1
|
-
require 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
|
2
1
|
require 'shoulda/matchers/integrations/test_frameworks/minitest_4'
|
3
2
|
require 'shoulda/matchers/integrations/test_frameworks/minitest_5'
|
4
3
|
require 'shoulda/matchers/integrations/test_frameworks/missing_test_framework'
|
5
4
|
require 'shoulda/matchers/integrations/test_frameworks/rspec'
|
6
|
-
require 'shoulda/matchers/integrations/test_frameworks/test_unit'
|
7
5
|
|
8
6
|
module Shoulda
|
9
7
|
module Matchers
|
10
8
|
module Integrations
|
11
9
|
# @private
|
12
10
|
module TestFrameworks
|
11
|
+
autoload :ActiveSupportTestCase, 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
|
12
|
+
autoload :Minitest4, 'shoulda/matchers/integrations/test_frameworks/minitest_4'
|
13
|
+
autoload :Minitest5, 'shoulda/matchers/integrations/test_frameworks/minitest_5'
|
14
|
+
autoload :TestUnit, 'shoulda/matchers/integrations/test_frameworks/test_unit'
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -21,6 +21,10 @@ module Shoulda
|
|
21
21
|
Gem::Requirement.new('>= 5').satisfied_by?(active_record_version)
|
22
22
|
end
|
23
23
|
|
24
|
+
def active_record_gte_6?
|
25
|
+
Gem::Requirement.new('>= 6').satisfied_by?(active_record_version)
|
26
|
+
end
|
27
|
+
|
24
28
|
def active_record_version
|
25
29
|
Gem::Version.new(::ActiveRecord::VERSION::STRING)
|
26
30
|
rescue NameError
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'shoulda/matchers/util/word_wrap'
|
2
|
-
|
3
1
|
module Shoulda
|
4
2
|
module Matchers
|
5
3
|
# @private
|
6
4
|
module Util
|
5
|
+
MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY = 500
|
6
|
+
|
7
7
|
def self.deconstantize(path)
|
8
8
|
if defined?(ActiveSupport::Inflector) &&
|
9
9
|
ActiveSupport::Inflector.respond_to?(:deconstantize)
|
@@ -47,7 +47,12 @@ module Shoulda
|
|
47
47
|
when Range
|
48
48
|
inspect_range(value)
|
49
49
|
else
|
50
|
-
|
50
|
+
inspected_value = value.inspect
|
51
|
+
if inspected_value.length > MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY
|
52
|
+
"‹#{inspected_value[0, MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY]}...›"
|
53
|
+
else
|
54
|
+
"‹#{inspected_value}›"
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
@@ -85,7 +90,7 @@ module Shoulda
|
|
85
90
|
when :datetime, :timestamp
|
86
91
|
DateTime.new(2100, 1, 1)
|
87
92
|
when :time
|
88
|
-
Time.new(
|
93
|
+
Time.new(2000, 1, 1)
|
89
94
|
when :uuid
|
90
95
|
SecureRandom.uuid
|
91
96
|
when :boolean
|
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: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tammer Saleh
|
@@ -11,10 +11,10 @@ authors:
|
|
11
11
|
- Matt Jankowski
|
12
12
|
- Stafford Brunk
|
13
13
|
- Elliot Winkler
|
14
|
-
autorequire:
|
14
|
+
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2020-
|
17
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activesupport
|
@@ -38,7 +38,6 @@ executables: []
|
|
38
38
|
extensions: []
|
39
39
|
extra_rdoc_files: []
|
40
40
|
files:
|
41
|
-
- MIT-LICENSE
|
42
41
|
- README.md
|
43
42
|
- docs/errors/NonCaseSwappableValueError.md
|
44
43
|
- lib/shoulda-matchers.rb
|
@@ -113,8 +112,10 @@ files:
|
|
113
112
|
- lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
|
114
113
|
- lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb
|
115
114
|
- lib/shoulda/matchers/active_record/define_enum_for_matcher.rb
|
115
|
+
- lib/shoulda/matchers/active_record/have_attached_matcher.rb
|
116
116
|
- lib/shoulda/matchers/active_record/have_db_column_matcher.rb
|
117
117
|
- lib/shoulda/matchers/active_record/have_db_index_matcher.rb
|
118
|
+
- lib/shoulda/matchers/active_record/have_implicit_order_column.rb
|
118
119
|
- lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb
|
119
120
|
- lib/shoulda/matchers/active_record/have_rich_text_matcher.rb
|
120
121
|
- lib/shoulda/matchers/active_record/have_secure_token_matcher.rb
|
@@ -138,7 +139,6 @@ files:
|
|
138
139
|
- lib/shoulda/matchers/error.rb
|
139
140
|
- lib/shoulda/matchers/independent.rb
|
140
141
|
- lib/shoulda/matchers/independent/delegate_method_matcher.rb
|
141
|
-
- lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
|
142
142
|
- lib/shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error.rb
|
143
143
|
- lib/shoulda/matchers/integrations.rb
|
144
144
|
- lib/shoulda/matchers/integrations/configuration.rb
|
@@ -177,7 +177,7 @@ metadata:
|
|
177
177
|
documentation_uri: https://matchers.shoulda.io/docs
|
178
178
|
homepage_uri: https://matchers.shoulda.io
|
179
179
|
source_code_uri: https://github.com/thoughtbot/shoulda-matchers
|
180
|
-
post_install_message:
|
180
|
+
post_install_message:
|
181
181
|
rdoc_options: []
|
182
182
|
require_paths:
|
183
183
|
- lib
|
@@ -192,8 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
196
|
-
signing_key:
|
195
|
+
rubygems_version: 3.1.2
|
196
|
+
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Simple one-liner tests for common Rails functionality
|
199
199
|
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2006-2020, Tammer Saleh and thoughtbot, inc.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person
|
4
|
-
obtaining a copy of this software and associated documentation
|
5
|
-
files (the "Software"), to deal in the Software without
|
6
|
-
restriction, including without limitation the rights to use,
|
7
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
copies of the Software, and to permit persons to whom the
|
9
|
-
Software is furnished to do so, subject to the following
|
10
|
-
conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Shoulda
|
2
|
-
module Matchers
|
3
|
-
module Independent
|
4
|
-
class DelegateMethodMatcher
|
5
|
-
# @private
|
6
|
-
class StubbedTarget
|
7
|
-
def initialize(method)
|
8
|
-
@received_method = false
|
9
|
-
@received_arguments = []
|
10
|
-
stub_method(method)
|
11
|
-
end
|
12
|
-
|
13
|
-
def has_received_method?
|
14
|
-
received_method
|
15
|
-
end
|
16
|
-
|
17
|
-
def has_received_arguments?(*args)
|
18
|
-
args == received_arguments
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
def stub_method(method)
|
24
|
-
class_eval do
|
25
|
-
define_method method do |*args|
|
26
|
-
@received_method = true
|
27
|
-
@received_arguments = args
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
attr_reader :received_method, :received_arguments
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|