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,26 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module Libraries
5
+ # @private
6
+ class ActiveRecord
7
+ Integrations.register_library(self, :active_record)
8
+
9
+ include Integrations::Inclusion
10
+ include Integrations::Rails
11
+
12
+ def integrate_with(test_framework)
13
+ test_framework.include(matchers_module, type: :model)
14
+ include_into(ActiveSupport::TestCase, matchers_module)
15
+ end
16
+
17
+ private
18
+
19
+ def matchers_module
20
+ Shoulda::Matchers::ActiveRecord
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module Libraries
5
+ # @private
6
+ class MissingLibrary
7
+ Integrations.register_library(self, :missing_library)
8
+
9
+ def integrate_with(test_framework)
10
+ end
11
+
12
+ def rails?
13
+ false
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module Libraries
5
+ # @private
6
+ class Rails
7
+ Integrations.register_library(self, :rails)
8
+
9
+ include Integrations::Rails
10
+
11
+ SUB_LIBRARIES = [
12
+ :active_model,
13
+ :active_record,
14
+ :action_controller,
15
+ :routing,
16
+ ].freeze
17
+
18
+ def integrate_with(test_framework)
19
+ Shoulda::Matchers.assertion_exception_class =
20
+ ActiveSupport::TestCase::Assertion
21
+
22
+ SUB_LIBRARIES.each do |name|
23
+ library = Integrations.find_library!(name)
24
+ library.integrate_with(test_framework)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module Libraries
5
+ # @private
6
+ class Routing
7
+ Integrations.register_library(self, :routing)
8
+
9
+ include Integrations::Inclusion
10
+ include Integrations::Rails
11
+
12
+ def integrate_with(test_framework)
13
+ test_framework.include(matchers_module, type: :routing)
14
+
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
20
+ end
21
+
22
+ def matchers_module
23
+ Shoulda::Matchers::Routing
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ require 'shoulda/matchers/integrations/libraries/action_controller'
2
+ require 'shoulda/matchers/integrations/libraries/active_model'
3
+ require 'shoulda/matchers/integrations/libraries/active_record'
4
+ require 'shoulda/matchers/integrations/libraries/missing_library'
5
+ require 'shoulda/matchers/integrations/libraries/rails'
6
+ require 'shoulda/matchers/integrations/libraries/routing'
7
+
8
+ module Shoulda
9
+ module Matchers
10
+ module Integrations
11
+ # @private
12
+ module Libraries
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ # @private
5
+ module Rails
6
+ def rails?
7
+ true
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ # @private
5
+ class Registry
6
+ def register(klass, name)
7
+ registry[name] = klass
8
+ end
9
+
10
+ def find!(name)
11
+ find_class!(name).new
12
+ end
13
+
14
+ private
15
+
16
+ def registry
17
+ @_registry ||= {}
18
+ end
19
+
20
+ def find_class!(name)
21
+ registry.fetch(name) do
22
+ raise ArgumentError, "'#{name}' is not registered"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class ActiveSupportTestCase
7
+ Integrations.register_test_framework(self, :active_support_test_case)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules, **_options)
13
+ test_case_class.include(*modules)
14
+ end
15
+
16
+ def n_unit?
17
+ true
18
+ end
19
+
20
+ def present?
21
+ true
22
+ end
23
+
24
+ protected
25
+
26
+ attr_reader :configuration
27
+
28
+ private
29
+
30
+ def test_case_class
31
+ ActiveSupport::TestCase
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class Minitest4
7
+ Integrations.register_test_framework(self, :minitest_4)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules, **_options)
13
+ test_case_class.class_eval do
14
+ include(*modules)
15
+ extend(*modules)
16
+ end
17
+ end
18
+
19
+ def n_unit?
20
+ true
21
+ end
22
+
23
+ def present?
24
+ true
25
+ end
26
+
27
+ private
28
+
29
+ def test_case_class
30
+ MiniTest::Unit::TestCase
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,37 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class Minitest5
7
+ Integrations.register_test_framework(self, :minitest_5)
8
+ Integrations.register_test_framework(self, :minitest)
9
+
10
+ def validate!
11
+ end
12
+
13
+ def include(*modules, **_options)
14
+ test_case_class.class_eval do
15
+ include(*modules)
16
+ extend(*modules)
17
+ end
18
+ end
19
+
20
+ def n_unit?
21
+ true
22
+ end
23
+
24
+ def present?
25
+ true
26
+ end
27
+
28
+ private
29
+
30
+ def test_case_class
31
+ Minitest::Test
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class MissingTestFramework
7
+ Integrations.register_test_framework(self, :missing_test_framework)
8
+
9
+ def validate!
10
+ raise TestFrameworkNotConfigured, <<-EOT
11
+ You need to set a test framework. Please add the following to your
12
+ test helper:
13
+
14
+ Shoulda::Matchers.configure do |config|
15
+ config.integrate do |with|
16
+ # Choose one:
17
+ with.test_framework :rspec
18
+ with.test_framework :minitest # or, :minitest_5
19
+ with.test_framework :minitest_4
20
+ with.test_framework :test_unit
21
+ end
22
+ end
23
+ EOT
24
+ end
25
+
26
+ def include(*modules, **options)
27
+ end
28
+
29
+ def n_unit?
30
+ false
31
+ end
32
+
33
+ def present?
34
+ false
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class Rspec
7
+ Integrations.register_test_framework(self, :rspec)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules, **options)
13
+ ::RSpec.configure do |config|
14
+ config.include(*modules, **options)
15
+ end
16
+ end
17
+
18
+ def n_unit?
19
+ false
20
+ end
21
+
22
+ def present?
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class TestUnit
7
+ Integrations.register_test_framework(self, :test_unit)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules, **_options)
13
+ test_case_class.class_eval do
14
+ include(*modules)
15
+ extend(*modules)
16
+ end
17
+ end
18
+
19
+ def n_unit?
20
+ true
21
+ end
22
+
23
+ def present?
24
+ true
25
+ end
26
+
27
+ private
28
+
29
+ def test_case_class
30
+ ::Test::Unit::TestCase
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ require 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
2
+ require 'shoulda/matchers/integrations/test_frameworks/minitest_4'
3
+ require 'shoulda/matchers/integrations/test_frameworks/minitest_5'
4
+ require 'shoulda/matchers/integrations/test_frameworks/missing_test_framework'
5
+ require 'shoulda/matchers/integrations/test_frameworks/rspec'
6
+ require 'shoulda/matchers/integrations/test_frameworks/test_unit'
7
+
8
+ module Shoulda
9
+ module Matchers
10
+ module Integrations
11
+ # @private
12
+ module TestFrameworks
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,43 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ module Integrations
5
+ class << self
6
+ def register_library(klass, name)
7
+ library_registry.register(klass, name)
8
+ end
9
+
10
+ def find_library!(name)
11
+ library_registry.find!(name)
12
+ end
13
+
14
+ def register_test_framework(klass, name)
15
+ test_framework_registry.register(klass, name)
16
+ end
17
+
18
+ def find_test_framework!(name)
19
+ test_framework_registry.find!(name)
20
+ end
21
+
22
+ private
23
+
24
+ def library_registry
25
+ @_library_registry ||= Registry.new
26
+ end
27
+
28
+ def test_framework_registry
29
+ @_test_framework_registry ||= Registry.new
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
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
+ require 'shoulda/matchers/integrations/libraries'
43
+ require 'shoulda/matchers/integrations/test_frameworks'
@@ -0,0 +1,99 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ class MatcherCollection
5
+ def self.build(attrs, &block)
6
+ new(attrs.map(&block))
7
+ end
8
+
9
+ def initialize(matchers)
10
+ @matchers = matchers
11
+ @failed_matchers = []
12
+ end
13
+
14
+ def description
15
+ matchers.map(&:description).join(' and ')
16
+ end
17
+
18
+ def matches?(subject)
19
+ @subject = subject
20
+ @failed_matchers = matchers.reject do |matcher|
21
+ matcher.matches?(fresh_subject_for(subject))
22
+ end
23
+ @failed_matchers.empty?
24
+ end
25
+
26
+ def does_not_match?(subject)
27
+ @subject = subject
28
+ @failed_matchers = matchers.reject do |matcher|
29
+ fresh_subject = fresh_subject_for(subject)
30
+ if matcher.respond_to?(:does_not_match?)
31
+ matcher.does_not_match?(fresh_subject)
32
+ else
33
+ !matcher.matches?(fresh_subject)
34
+ end
35
+ end
36
+ @failed_matchers.empty?
37
+ end
38
+
39
+ def failure_message
40
+ if matchers.one?
41
+ matchers.first.failure_message
42
+ else
43
+ build_failure_message('to')
44
+ end
45
+ end
46
+
47
+ def failure_message_when_negated
48
+ if matchers.one?
49
+ matchers.first.failure_message_when_negated
50
+ else
51
+ build_failure_message('not to')
52
+ end
53
+ end
54
+
55
+ def method_missing(method, *args, &block)
56
+ if all_matchers_respond_to?(method)
57
+ matchers.each { |matcher| matcher.send(method, *args, &block) }
58
+ self
59
+ else
60
+ super
61
+ end
62
+ end
63
+
64
+ def respond_to_missing?(method, include_private = false)
65
+ all_matchers_respond_to?(method) || super
66
+ end
67
+
68
+ private
69
+
70
+ attr_reader :matchers
71
+
72
+ def fresh_subject_for(subject)
73
+ matchers.one? ? subject : subject.dup
74
+ end
75
+
76
+ def build_failure_message(direction)
77
+ header = Shoulda::Matchers.word_wrap(
78
+ "Expected #{@subject.class.name} #{direction} "\
79
+ "#{failed_description}, but this could not be proved.",
80
+ )
81
+
82
+ reasons = @failed_matchers.filter_map do |matcher|
83
+ reason = matcher.failure_reason
84
+ Shoulda::Matchers.word_wrap(reason, indent: 2) if reason.present?
85
+ end
86
+
87
+ ([header] + reasons).join("\n")
88
+ end
89
+
90
+ def failed_description
91
+ @failed_matchers.map(&:description).join(' and ')
92
+ end
93
+
94
+ def all_matchers_respond_to?(method)
95
+ matchers.all? { |matcher| matcher.respond_to?(method) }
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,36 @@
1
+ module Shoulda
2
+ module Matchers
3
+ # @private
4
+ class MatcherContext
5
+ def initialize(context)
6
+ @context = context
7
+ end
8
+
9
+ def subject_is_a_class?
10
+ if inside_a_shoulda_context_project? && outside_a_should_block?
11
+ assume_that_subject_is_not_a_class
12
+ else
13
+ context.subject.is_a?(Class)
14
+ end
15
+ end
16
+
17
+ protected
18
+
19
+ attr_reader :context
20
+
21
+ private
22
+
23
+ def inside_a_shoulda_context_project?
24
+ defined?(Shoulda::Context)
25
+ end
26
+
27
+ def outside_a_should_block?
28
+ context.is_a?(Class)
29
+ end
30
+
31
+ def assume_that_subject_is_not_a_class
32
+ false
33
+ end
34
+ end
35
+ end
36
+ end