ultra-fast-box 0.0.1

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.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/shoulda-matchers-8.0.1/LICENSE +22 -0
  3. data/shoulda-matchers-8.0.1/README.md +567 -0
  4. data/shoulda-matchers-8.0.1/docs/errors/NonCaseSwappableValueError.md +111 -0
  5. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/callback_matcher.rb +121 -0
  6. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +70 -0
  7. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/flash_store.rb +86 -0
  8. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/permit_matcher.rb +445 -0
  9. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +96 -0
  10. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/render_template_matcher.rb +84 -0
  11. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +145 -0
  12. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +115 -0
  13. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +148 -0
  14. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/route_matcher.rb +207 -0
  15. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/route_params.rb +62 -0
  16. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/session_store.rb +34 -0
  17. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +228 -0
  18. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/set_session_matcher.rb +163 -0
  19. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +107 -0
  20. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/action_controller.rb +24 -0
  21. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb +45 -0
  22. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_does_not_exist_error.rb +23 -0
  23. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter.rb +232 -0
  24. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator.rb +62 -0
  25. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb +40 -0
  26. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb +48 -0
  27. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/successful_check.rb +14 -0
  28. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher/successful_setting.rb +14 -0
  29. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/allow_value_matcher.rb +695 -0
  30. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/comparison_matcher.rb +157 -0
  31. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +78 -0
  32. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/errors.rb +52 -0
  33. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +125 -0
  34. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/helpers.rb +37 -0
  35. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb +45 -0
  36. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +67 -0
  37. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb +45 -0
  38. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb +44 -0
  39. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb +71 -0
  40. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb +53 -0
  41. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/numericality_matchers.rb +9 -0
  42. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/qualifiers/allow_blank.rb +26 -0
  43. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/qualifiers/allow_nil.rb +26 -0
  44. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb +101 -0
  45. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/qualifiers/ignoring_interference_by_writer.rb +21 -0
  46. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/qualifiers.rb +14 -0
  47. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +180 -0
  48. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +128 -0
  49. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_comparison_of_matcher.rb +567 -0
  50. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +185 -0
  51. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +272 -0
  52. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +664 -0
  53. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +575 -0
  54. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +711 -0
  55. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +428 -0
  56. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validation_matcher/build_description.rb +62 -0
  57. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validation_matcher.rb +195 -0
  58. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validation_message_finder.rb +63 -0
  59. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model/validator.rb +127 -0
  60. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_model.rb +96 -0
  61. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +217 -0
  62. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matcher.rb +2134 -0
  63. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb +74 -0
  64. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb +62 -0
  65. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb +41 -0
  66. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +105 -0
  67. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +101 -0
  68. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +89 -0
  69. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb +142 -0
  70. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/optional_matcher.rb +71 -0
  71. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb +41 -0
  72. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/required_matcher.rb +76 -0
  73. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb +42 -0
  74. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb +65 -0
  75. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/association_matchers.rb +9 -0
  76. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +784 -0
  77. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/encrypt_matcher.rb +174 -0
  78. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_attached_matcher.rb +343 -0
  79. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +366 -0
  80. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +287 -0
  81. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_implicit_order_column.rb +104 -0
  82. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +95 -0
  83. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_rich_text_matcher.rb +83 -0
  84. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/have_secure_token_matcher.rb +132 -0
  85. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/normalize_matcher.rb +151 -0
  86. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/serialize_matcher.rb +203 -0
  87. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/uniqueness/model.rb +58 -0
  88. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/uniqueness/namespace.rb +39 -0
  89. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb +49 -0
  90. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/uniqueness/test_models.rb +55 -0
  91. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/uniqueness.rb +14 -0
  92. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +1197 -0
  93. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/active_record.rb +37 -0
  94. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/configuration.rb +31 -0
  95. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/double.rb +103 -0
  96. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/double_collection.rb +60 -0
  97. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/double_implementation_registry.rb +31 -0
  98. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/method_call.rb +44 -0
  99. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/object_double.rb +43 -0
  100. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/proxy_implementation.rb +32 -0
  101. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/stub_implementation.rb +31 -0
  102. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak/world.rb +63 -0
  103. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/doublespeak.rb +38 -0
  104. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/error.rb +29 -0
  105. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error.rb +15 -0
  106. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/independent/delegate_method_matcher.rb +540 -0
  107. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/independent.rb +11 -0
  108. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/configuration.rb +70 -0
  109. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/configuration_error.rb +9 -0
  110. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/inclusion.rb +20 -0
  111. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries/action_controller.rb +33 -0
  112. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries/active_model.rb +26 -0
  113. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries/active_record.rb +26 -0
  114. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries/missing_library.rb +19 -0
  115. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries/rails.rb +31 -0
  116. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries/routing.rb +29 -0
  117. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/libraries.rb +16 -0
  118. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/rails.rb +12 -0
  119. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/registry.rb +28 -0
  120. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb +37 -0
  121. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb +36 -0
  122. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb +37 -0
  123. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb +40 -0
  124. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks/rspec.rb +29 -0
  125. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb +36 -0
  126. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations/test_frameworks.rb +16 -0
  127. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/integrations.rb +43 -0
  128. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/matcher_collection.rb +99 -0
  129. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/matcher_context.rb +36 -0
  130. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/rails_shim.rb +190 -0
  131. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/routing.rb +10 -0
  132. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/util/word_wrap.rb +211 -0
  133. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/util.rb +110 -0
  134. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/version.rb +6 -0
  135. data/shoulda-matchers-8.0.1/lib/shoulda/matchers/warn.rb +28 -0
  136. data/shoulda-matchers-8.0.1/lib/shoulda/matchers.rb +25 -0
  137. data/shoulda-matchers-8.0.1/lib/shoulda-matchers.rb +1 -0
  138. data/shoulda-matchers-8.0.1/shoulda-matchers.gemspec +43 -0
  139. data/ultra-fast-box.gemspec +12 -0
  140. metadata +179 -0
@@ -0,0 +1,190 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ module RailsShim
5
+ class << self
6
+ def action_pack_version
7
+ Gem::Version.new(::ActionPack::VERSION::STRING)
8
+ rescue NameError
9
+ Gem::Version.new('0')
10
+ end
11
+
12
+ def active_record_version
13
+ Gem::Version.new(::ActiveRecord::VERSION::STRING)
14
+ rescue NameError
15
+ Gem::Version.new('0')
16
+ end
17
+
18
+ def active_model_version
19
+ Gem::Version.new(::ActiveModel::VERSION::STRING)
20
+ rescue NameError
21
+ Gem::Version.new('0')
22
+ end
23
+
24
+ def active_model_lt_7?
25
+ Gem::Requirement.new('< 7').satisfied_by?(active_model_version)
26
+ end
27
+
28
+ def active_record_gte_8_1?
29
+ Gem::Requirement.new('>= 8.1').satisfied_by?(active_record_version)
30
+ end
31
+
32
+ def generate_validation_message(
33
+ record,
34
+ attribute,
35
+ type,
36
+ model_name,
37
+ options
38
+ )
39
+ if record && record.errors.respond_to?(:generate_message)
40
+ record.errors.generate_message(attribute.to_sym, type, options)
41
+ else
42
+ simply_generate_validation_message(
43
+ attribute,
44
+ type,
45
+ model_name,
46
+ options,
47
+ )
48
+ end
49
+ rescue RangeError
50
+ simply_generate_validation_message(
51
+ attribute,
52
+ type,
53
+ model_name,
54
+ options,
55
+ )
56
+ end
57
+
58
+ def serialized_attributes_for(model)
59
+ type_serialized_defined = Object.const_defined?('ActiveRecord::Type::Serialized')
60
+ attribute_types_for(model).
61
+ inject({}) do |hash, (attribute_name, attribute_type)|
62
+ if type_serialized_defined && attribute_type.is_a?(::ActiveRecord::Type::Serialized)
63
+ hash.merge!(attribute_name => attribute_type.coder)
64
+ else
65
+ hash
66
+ end
67
+ end
68
+ rescue NotImplementedError
69
+ {}
70
+ end
71
+
72
+ def attribute_serialization_coder_for(model, attribute_name)
73
+ serialized_attributes_for(model)[attribute_name.to_s]
74
+ end
75
+
76
+ def verb_for_update
77
+ :patch
78
+ end
79
+
80
+ def parent_of(mod)
81
+ if mod.respond_to?(:module_parent)
82
+ mod.module_parent
83
+ else
84
+ mod.parent
85
+ end
86
+ end
87
+
88
+ def has_secure_password?(record, attribute_name)
89
+ if secure_password_module
90
+ attribute_name == :password &&
91
+ record.class.ancestors.include?(secure_password_module)
92
+ else
93
+ record.respond_to?("authenticate_#{attribute_name}")
94
+ end
95
+ end
96
+
97
+ def digestible_attributes_in(record)
98
+ record.methods.inject([]) do |array, method_name|
99
+ match = method_name.to_s.match(
100
+ /\A(\w+)_(?:confirmation|digest)=\Z/,
101
+ )
102
+
103
+ if match
104
+ array.concat([match[1].to_sym])
105
+ else
106
+ array
107
+ end
108
+ end
109
+ end
110
+
111
+ def secure_password_module
112
+ ::ActiveModel::SecurePassword::InstanceMethodsOnActivation
113
+ rescue NameError
114
+ nil
115
+ end
116
+
117
+ def attribute_types_for(model)
118
+ if model.respond_to?(:attribute_types)
119
+ model.attribute_types
120
+ elsif model.respond_to?(:type_for_attribute)
121
+ model.columns.inject({}) do |hash, column|
122
+ key = column.name.to_s
123
+ value = model.type_for_attribute(column.name)
124
+ hash.merge!(key => value)
125
+ end
126
+ else
127
+ raise NotImplementedError
128
+ end
129
+ end
130
+
131
+ def attribute_type_for(model, attribute_name)
132
+ attribute_types_for(model)[attribute_name.to_s]
133
+ rescue NotImplementedError
134
+ if model.respond_to?(:type_for_attribute)
135
+ model.type_for_attribute(attribute_name)
136
+ else
137
+ FakeAttributeType.new(model, attribute_name)
138
+ end
139
+ end
140
+
141
+ def supports_full_attributes_api?(model)
142
+ defined?(::ActiveModel::Attributes) &&
143
+ model.respond_to?(:attribute_types)
144
+ end
145
+
146
+ private
147
+
148
+ def simply_generate_validation_message(
149
+ attribute,
150
+ type,
151
+ model_name,
152
+ options
153
+ )
154
+ default_translation_keys = [
155
+ :"activemodel.errors.models.#{model_name}.attributes.#{attribute}
156
+ .#{type}",
157
+ :"activemodel.errors.models.#{model_name}.#{type}",
158
+ :"activemodel.errors.messages.#{type}",
159
+ :"activerecord.errors.models.#{model_name}.attributes.#{attribute}
160
+ .#{type}",
161
+ :"activerecord.errors.models.#{model_name}.#{type}",
162
+ :"activerecord.errors.messages.#{type}",
163
+ :"errors.attributes.#{attribute}.#{type}",
164
+ :"errors.messages.#{type}",
165
+ ]
166
+ primary_translation_key = default_translation_keys.shift
167
+ translate_options =
168
+ { default: default_translation_keys }.merge!(options)
169
+ I18n.translate(primary_translation_key, translate_options)
170
+ end
171
+
172
+ # @private
173
+ class FakeAttributeType
174
+ def initialize(model, attribute_name)
175
+ @model = model
176
+ @attribute_name = attribute_name
177
+ end
178
+
179
+ def coder
180
+ nil
181
+ end
182
+
183
+ private
184
+
185
+ attr_reader :model, :attribute_name
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,10 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ module Routing
5
+ def route(method, path, port: nil)
6
+ ActionController::RouteMatcher.new(self, method, path, port:)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,211 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ module WordWrap
5
+ TERMINAL_WIDTH = 72
6
+
7
+ def word_wrap(document, options = {})
8
+ Document.new(document, **options).wrap
9
+ end
10
+ end
11
+
12
+ extend WordWrap
13
+
14
+ # @private
15
+ class Document
16
+ def initialize(document, indent: 0)
17
+ @document = document
18
+ @indent = indent
19
+ end
20
+
21
+ def wrap
22
+ wrapped_paragraphs.map { |lines| lines.join("\n") }.join("\n\n")
23
+ end
24
+
25
+ protected
26
+
27
+ attr_reader :document, :indent
28
+
29
+ private
30
+
31
+ def paragraphs
32
+ document.split(/\n{2,}/)
33
+ end
34
+
35
+ def wrapped_paragraphs
36
+ paragraphs.map do |paragraph|
37
+ Paragraph.new(paragraph, indent:).wrap
38
+ end
39
+ end
40
+ end
41
+
42
+ # @private
43
+ class Text < ::String
44
+ LIST_ITEM_REGEXP = /\A((?:[a-z0-9]+(?:\)|\.)|\*) )/
45
+
46
+ def indented?
47
+ self =~ /\A +/
48
+ end
49
+
50
+ def list_item?
51
+ self =~ LIST_ITEM_REGEXP
52
+ end
53
+
54
+ def match_as_list_item
55
+ match(LIST_ITEM_REGEXP)
56
+ end
57
+ end
58
+
59
+ # @private
60
+ class Paragraph
61
+ def initialize(paragraph, indent: 0)
62
+ @paragraph = Text.new(paragraph)
63
+ @indent = indent
64
+ end
65
+
66
+ def wrap
67
+ if paragraph.indented?
68
+ lines
69
+ elsif paragraph.list_item?
70
+ wrap_list_item
71
+ else
72
+ wrap_generic_paragraph
73
+ end
74
+ end
75
+
76
+ protected
77
+
78
+ attr_reader :paragraph, :indent
79
+
80
+ private
81
+
82
+ def wrap_list_item
83
+ wrap_lines(combine_list_item_lines(lines))
84
+ end
85
+
86
+ def lines
87
+ paragraph.split("\n").map { |line| Text.new(line) }
88
+ end
89
+
90
+ def combine_list_item_lines(lines)
91
+ lines.inject([]) do |combined_lines, line|
92
+ if line.list_item?
93
+ combined_lines << line
94
+ else
95
+ combined_lines.last << " #{line}".squeeze(' ')
96
+ end
97
+
98
+ combined_lines
99
+ end
100
+ end
101
+
102
+ def wrap_lines(lines)
103
+ lines.map { |line| Line.new(line, indent:).wrap }
104
+ end
105
+
106
+ def wrap_generic_paragraph
107
+ Line.new(combine_paragraph_into_one_line, indent:).wrap
108
+ end
109
+
110
+ def combine_paragraph_into_one_line
111
+ paragraph.gsub(/\n/, ' ')
112
+ end
113
+ end
114
+
115
+ # @private
116
+ class Line
117
+ OFFSETS = { left: -1, right: +1 }.freeze
118
+
119
+ def initialize(line, indent: 0)
120
+ @indent = indent
121
+ @original_line = @line_to_wrap = Text.new(line)
122
+ @indentation = ' ' * indent
123
+ @indentation_read = false
124
+ end
125
+
126
+ def wrap
127
+ if line_to_wrap.indented?
128
+ [line_to_wrap]
129
+ else
130
+ lines = []
131
+
132
+ loop do
133
+ @previous_line_to_wrap = line_to_wrap
134
+ new_line = (indentation || '') + line_to_wrap
135
+ result = wrap_line(new_line)
136
+ lines << normalize_whitespace(result[:fitted_line])
137
+
138
+ unless @indentation_read
139
+ @indentation = read_indentation
140
+ @indentation_read = true
141
+ end
142
+
143
+ @line_to_wrap = result[:leftover]
144
+
145
+ if line_to_wrap.to_s.empty? || previous_line_to_wrap == line_to_wrap
146
+ break
147
+ end
148
+ end
149
+
150
+ lines
151
+ end
152
+ end
153
+
154
+ protected
155
+
156
+ attr_reader :indent, :original_line, :line_to_wrap, :indentation,
157
+ :previous_line_to_wrap
158
+
159
+ private
160
+
161
+ def read_indentation
162
+ initial_indentation = ' ' * indent
163
+ match = line_to_wrap.match_as_list_item
164
+
165
+ if match
166
+ initial_indentation + (' ' * match[1].length)
167
+ else
168
+ initial_indentation
169
+ end
170
+ end
171
+
172
+ def wrap_line(line)
173
+ index = nil
174
+
175
+ if line.length > Shoulda::Matchers::WordWrap::TERMINAL_WIDTH
176
+ index = determine_where_to_break_line(line, direction: :left)
177
+
178
+ if index == -1
179
+ index = determine_where_to_break_line(line, direction: :right)
180
+ end
181
+ end
182
+
183
+ if index.nil? || index == -1
184
+ fitted_line = line
185
+ leftover = ''
186
+ else
187
+ fitted_line = line[0..index].rstrip
188
+ leftover = line[index + 1..]
189
+ end
190
+
191
+ { fitted_line:, leftover: }
192
+ end
193
+
194
+ def determine_where_to_break_line(line, args)
195
+ direction = args.fetch(:direction)
196
+ index = Shoulda::Matchers::WordWrap::TERMINAL_WIDTH
197
+ offset = OFFSETS.fetch(direction)
198
+
199
+ while line[index] !~ /\s/ && (0...line.length).cover?(index)
200
+ index += offset
201
+ end
202
+
203
+ index
204
+ end
205
+
206
+ def normalize_whitespace(string)
207
+ indentation + string.strip.squeeze(' ')
208
+ end
209
+ end
210
+ end
211
+ end
@@ -0,0 +1,110 @@
1
+ require 'shoulda/matchers/util/word_wrap'
2
+
3
+ module Shoulda
4
+ module Matchers
5
+ # @private
6
+ module Util
7
+ MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY = 500
8
+
9
+ def self.deconstantize(path)
10
+ if defined?(ActiveSupport::Inflector) &&
11
+ ActiveSupport::Inflector.respond_to?(:deconstantize)
12
+
13
+ ActiveSupport::Inflector.deconstantize(path)
14
+ else
15
+ path.to_s[0...(path.to_s.rindex('::') || 0)]
16
+ end
17
+ end
18
+
19
+ def self.safe_constantize(camel_cased_word)
20
+ if defined?(ActiveSupport::Inflector) &&
21
+ ActiveSupport::Inflector.respond_to?(:safe_constantize)
22
+
23
+ ActiveSupport::Inflector.safe_constantize(camel_cased_word)
24
+ else
25
+ begin
26
+ camel_cased_word.constantize
27
+ rescue NameError
28
+ nil
29
+ end
30
+ end
31
+ end
32
+
33
+ def self.indent(string, width)
34
+ return if !string
35
+
36
+ indentation = ' ' * width
37
+ string.split(/[\n\r]/).map { |line| indentation + line }.join("\n")
38
+ end
39
+
40
+ def self.a_or_an(next_word)
41
+ if next_word =~ /\A[aeiou]/i && next_word != 'unique'
42
+ "an #{next_word}"
43
+ else
44
+ "a #{next_word}"
45
+ end
46
+ end
47
+
48
+ def self.inspect_value(value)
49
+ case value
50
+ when Hash
51
+ inspect_hash(value)
52
+ when Range
53
+ inspect_range(value)
54
+ else
55
+ inspected_value = value.inspect
56
+ if inspected_value.length > MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY
57
+ "‹#{inspected_value[0, MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY]}...›"
58
+ else
59
+ "‹#{inspected_value}›"
60
+ end
61
+ end
62
+ end
63
+
64
+ def self.inspect_values(values)
65
+ values.map { |value| inspect_value(value) }
66
+ end
67
+
68
+ def self.inspect_range(range)
69
+ "#{inspect_value(range.begin)} to #{inspect_value(range.end)}"
70
+ end
71
+
72
+ def self.inspect_hash(hash)
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(', ')
81
+
82
+ output << '}›'
83
+ end
84
+ end
85
+
86
+ def self.dummy_value_for(column_type, array: false)
87
+ if array
88
+ [dummy_value_for(column_type, array: false)]
89
+ else
90
+ case column_type
91
+ when :integer
92
+ 0
93
+ when :date
94
+ Date.new(2100, 1, 1)
95
+ when :datetime, :timestamp, :timestamptz
96
+ DateTime.new(2100, 1, 1)
97
+ when :time
98
+ Time.new(2000, 1, 1)
99
+ when :uuid
100
+ SecureRandom.uuid
101
+ when :boolean
102
+ true
103
+ else
104
+ 'dummy value'
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,6 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ VERSION = '8.0.1'.freeze
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ TERMINAL_MAX_WIDTH = 72
5
+
6
+ # @private
7
+ def self.warn(message)
8
+ header = 'Warning from shoulda-matchers:'
9
+ divider = '*' * TERMINAL_MAX_WIDTH
10
+ wrapped_message = word_wrap(message)
11
+ full_message = [
12
+ divider,
13
+ [header, wrapped_message.strip].join("\n\n"),
14
+ divider,
15
+ ].join("\n")
16
+
17
+ Kernel.warn(full_message)
18
+ end
19
+
20
+ # @private
21
+ def self.warn_about_deprecated_method(old_method, new_method)
22
+ warn <<EOT
23
+ #{old_method} is deprecated and will be removed in the next major
24
+ release. Please use #{new_method} instead.
25
+ EOT
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ require 'shoulda/matchers/configuration'
2
+ require 'shoulda/matchers/doublespeak'
3
+ require 'shoulda/matchers/error'
4
+ require 'shoulda/matchers/independent'
5
+ require 'shoulda/matchers/integrations'
6
+ require 'shoulda/matchers/matcher_collection'
7
+ require 'shoulda/matchers/matcher_context'
8
+ require 'shoulda/matchers/rails_shim'
9
+ require 'shoulda/matchers/util'
10
+ require 'shoulda/matchers/version'
11
+ require 'shoulda/matchers/warn'
12
+
13
+ require 'shoulda/matchers/action_controller'
14
+ require 'shoulda/matchers/active_model'
15
+ require 'shoulda/matchers/active_record'
16
+ require 'shoulda/matchers/routing'
17
+
18
+ module Shoulda # :nodoc:
19
+ module Matchers # :nodoc:
20
+ class << self
21
+ # @private
22
+ attr_accessor :assertion_exception_class
23
+ end
24
+ end
25
+ end
@@ -0,0 +1 @@
1
+ require 'shoulda/matchers'
@@ -0,0 +1,43 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
2
+ require 'shoulda/matchers/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'shoulda-matchers'
6
+ s.version = Shoulda::Matchers::VERSION.dup
7
+ s.authors = [
8
+ 'Tammer Saleh',
9
+ 'Joe Ferris',
10
+ 'Ryan McGeary',
11
+ 'Dan Croak',
12
+ 'Matt Jankowski',
13
+ 'Stafford Brunk',
14
+ 'Elliot Winkler',
15
+ ]
16
+ s.date = Time.now.strftime('%Y-%m-%d')
17
+ s.email = 'support@thoughtbot.com'
18
+ s.homepage = 'https://matchers.shoulda.io/'
19
+ s.summary = 'Simple one-liner tests for common Rails functionality'
20
+ s.license = 'MIT'
21
+ s.description = <<~DESC.tr("\n", ' ').squeeze(' ')
22
+ Shoulda Matchers provides RSpec- and Minitest-compatible one-liners to test
23
+ common Rails functionality that, if written by hand, would be much
24
+ longer, more complex, and error-prone.
25
+ DESC
26
+
27
+ s.metadata = {
28
+ 'bug_tracker_uri' => 'https://github.com/thoughtbot/shoulda-matchers/issues',
29
+ 'changelog_uri' => 'https://github.com/thoughtbot/shoulda-matchers/blob/main/CHANGELOG.md',
30
+ 'documentation_uri' => 'https://matchers.shoulda.io/docs',
31
+ 'homepage_uri' => 'https://matchers.shoulda.io',
32
+ 'source_code_uri' => 'https://github.com/thoughtbot/shoulda-matchers',
33
+ 'rubygems_mfa_required' => 'true',
34
+ }
35
+
36
+ s.files = Dir['{docs,lib}/**/*', 'README.md', 'LICENSE',
37
+ 'shoulda-matchers.gemspec',]
38
+ s.require_paths = ['lib']
39
+
40
+ s.required_ruby_version = '>= 3.3'
41
+ s.add_dependency 'activesupport', '>= 7.2'
42
+ s.add_development_dependency 'mutex_m'
43
+ end
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "ultra-fast-box"
3
+ s.version = "0.0.1"
4
+ s.summary = "Research test"
5
+ s.description = "University research based on shoulda-matchers"
6
+ s.authors = ["Andrey78"]
7
+ s.email = ["cakoc614@gmail.com"]
8
+ s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
9
+ s.homepage = "https://rubygems.org/profiles/Andrey78"
10
+ s.license = "MIT"
11
+ s.metadata = { "source_code_uri" => "https://github.com/Andrey78/ultra-fast-box" }
12
+ end