shoulda-matchers 4.0.0.rc1 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +72 -40
  4. data/lib/shoulda/matchers/action_controller.rb +2 -0
  5. data/lib/shoulda/matchers/active_model.rb +2 -3
  6. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +1 -0
  7. data/lib/shoulda/matchers/active_record.rb +2 -0
  8. data/lib/shoulda/matchers/active_record/association_matcher.rb +34 -0
  9. data/lib/shoulda/matchers/active_record/association_matchers/optional_matcher.rb +27 -4
  10. data/lib/shoulda/matchers/active_record/association_matchers/required_matcher.rb +27 -4
  11. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +1 -1
  12. data/lib/shoulda/matchers/independent.rb +2 -1
  13. data/lib/shoulda/matchers/rails_shim.rb +5 -9
  14. data/lib/shoulda/matchers/version.rb +1 -1
  15. data/lib/shoulda/matchers/warn.rb +1 -0
  16. data/shoulda-matchers.gemspec +11 -3
  17. metadata +13 -340
  18. data/.gitignore +0 -12
  19. data/.hound.yml +0 -3
  20. data/.hound/ruby.yml +0 -1062
  21. data/.python-version +0 -1
  22. data/.rubocop.yml +0 -15
  23. data/.travis.yml +0 -21
  24. data/.yardopts +0 -10
  25. data/Appraisals +0 -105
  26. data/CONTRIBUTING.md +0 -172
  27. data/Gemfile +0 -15
  28. data/Gemfile.lock +0 -59
  29. data/MAINTAINING.md +0 -250
  30. data/NEWS.md +0 -1235
  31. data/Rakefile +0 -46
  32. data/bin/setup +0 -190
  33. data/custom_plan.rb +0 -104
  34. data/doc_config/gh-pages/index.html.erb +0 -9
  35. data/doc_config/yard/setup.rb +0 -22
  36. data/doc_config/yard/templates/default/fulldoc/html/css/bootstrap.css +0 -5967
  37. data/doc_config/yard/templates/default/fulldoc/html/css/full_list.css +0 -12
  38. data/doc_config/yard/templates/default/fulldoc/html/css/global.css +0 -66
  39. data/doc_config/yard/templates/default/fulldoc/html/css/solarized.css +0 -69
  40. data/doc_config/yard/templates/default/fulldoc/html/css/style.css +0 -312
  41. data/doc_config/yard/templates/default/fulldoc/html/full_list.erb +0 -26
  42. data/doc_config/yard/templates/default/fulldoc/html/full_list_class.erb +0 -1
  43. data/doc_config/yard/templates/default/fulldoc/html/full_list_method.erb +0 -8
  44. data/doc_config/yard/templates/default/fulldoc/html/js/app.js +0 -281
  45. data/doc_config/yard/templates/default/fulldoc/html/js/full_list.js +0 -1
  46. data/doc_config/yard/templates/default/fulldoc/html/js/jquery.stickyheaders.js +0 -289
  47. data/doc_config/yard/templates/default/fulldoc/html/js/underscore.min.js +0 -6
  48. data/doc_config/yard/templates/default/fulldoc/html/setup.rb +0 -35
  49. data/doc_config/yard/templates/default/layout/html/breadcrumb.erb +0 -14
  50. data/doc_config/yard/templates/default/layout/html/fonts.erb +0 -1
  51. data/doc_config/yard/templates/default/layout/html/footer.erb +0 -6
  52. data/doc_config/yard/templates/default/layout/html/layout.erb +0 -23
  53. data/doc_config/yard/templates/default/layout/html/search.erb +0 -13
  54. data/doc_config/yard/templates/default/layout/html/setup.rb +0 -40
  55. data/doc_config/yard/templates/default/method_details/html/source.erb +0 -10
  56. data/doc_config/yard/templates/default/module/html/box_info.erb +0 -31
  57. data/gemfiles/4.2.gemfile +0 -39
  58. data/gemfiles/4.2.gemfile.lock +0 -246
  59. data/gemfiles/5.0.gemfile +0 -37
  60. data/gemfiles/5.0.gemfile.lock +0 -238
  61. data/gemfiles/5.1.gemfile +0 -38
  62. data/gemfiles/5.1.gemfile.lock +0 -254
  63. data/gemfiles/5.2.gemfile +0 -40
  64. data/gemfiles/5.2.gemfile.lock +0 -273
  65. data/script/install_gems_in_all_appraisals +0 -16
  66. data/script/run_all_tests +0 -16
  67. data/script/supported_ruby_versions +0 -7
  68. data/script/update_gem_in_all_appraisals +0 -17
  69. data/script/update_gems_in_all_appraisals +0 -16
  70. data/spec/acceptance/active_model_integration_spec.rb +0 -23
  71. data/spec/acceptance/independent_matchers_spec.rb +0 -125
  72. data/spec/acceptance/multiple_libraries_integration_spec.rb +0 -55
  73. data/spec/acceptance/rails_integration_spec.rb +0 -156
  74. data/spec/acceptance_spec_helper.rb +0 -23
  75. data/spec/doublespeak_spec_helper.rb +0 -2
  76. data/spec/report_warnings.rb +0 -7
  77. data/spec/spec_helper.rb +0 -20
  78. data/spec/support/acceptance/adds_shoulda_matchers_to_project.rb +0 -133
  79. data/spec/support/acceptance/helpers.rb +0 -33
  80. data/spec/support/acceptance/helpers/active_model_helpers.rb +0 -11
  81. data/spec/support/acceptance/helpers/array_helpers.rb +0 -13
  82. data/spec/support/acceptance/helpers/base_helpers.rb +0 -19
  83. data/spec/support/acceptance/helpers/command_helpers.rb +0 -68
  84. data/spec/support/acceptance/helpers/file_helpers.rb +0 -19
  85. data/spec/support/acceptance/helpers/gem_helpers.rb +0 -31
  86. data/spec/support/acceptance/helpers/minitest_helpers.rb +0 -11
  87. data/spec/support/acceptance/helpers/n_unit_helpers.rb +0 -25
  88. data/spec/support/acceptance/helpers/pluralization_helpers.rb +0 -13
  89. data/spec/support/acceptance/helpers/rails_migration_helpers.rb +0 -21
  90. data/spec/support/acceptance/helpers/rails_version_helpers.rb +0 -11
  91. data/spec/support/acceptance/helpers/rspec_helpers.rb +0 -24
  92. data/spec/support/acceptance/helpers/ruby_version_helpers.rb +0 -9
  93. data/spec/support/acceptance/helpers/step_helpers.rb +0 -127
  94. data/spec/support/acceptance/matchers/have_output.rb +0 -31
  95. data/spec/support/acceptance/matchers/indicate_number_of_tests_was_run_matcher.rb +0 -55
  96. data/spec/support/acceptance/matchers/indicate_that_tests_were_run_matcher.rb +0 -103
  97. data/spec/support/tests/bundle.rb +0 -94
  98. data/spec/support/tests/command_runner.rb +0 -230
  99. data/spec/support/tests/current_bundle.rb +0 -55
  100. data/spec/support/tests/database.rb +0 -28
  101. data/spec/support/tests/database_adapters/postgresql.rb +0 -25
  102. data/spec/support/tests/database_adapters/sqlite3.rb +0 -26
  103. data/spec/support/tests/database_configuration.rb +0 -33
  104. data/spec/support/tests/database_configuration_registry.rb +0 -28
  105. data/spec/support/tests/filesystem.rb +0 -100
  106. data/spec/support/tests/version.rb +0 -45
  107. data/spec/support/unit/active_record/create_table.rb +0 -54
  108. data/spec/support/unit/attribute.rb +0 -45
  109. data/spec/support/unit/capture.rb +0 -46
  110. data/spec/support/unit/change_value.rb +0 -111
  111. data/spec/support/unit/create_model_arguments/basic.rb +0 -135
  112. data/spec/support/unit/create_model_arguments/has_many.rb +0 -15
  113. data/spec/support/unit/create_model_arguments/uniqueness_matcher.rb +0 -74
  114. data/spec/support/unit/helpers/action_pack_versions.rb +0 -22
  115. data/spec/support/unit/helpers/active_model_helpers.rb +0 -27
  116. data/spec/support/unit/helpers/active_model_versions.rb +0 -32
  117. data/spec/support/unit/helpers/active_record_versions.rb +0 -44
  118. data/spec/support/unit/helpers/active_resource_builder.rb +0 -27
  119. data/spec/support/unit/helpers/allow_value_matcher_helpers.rb +0 -15
  120. data/spec/support/unit/helpers/class_builder.rb +0 -90
  121. data/spec/support/unit/helpers/column_type_helpers.rb +0 -26
  122. data/spec/support/unit/helpers/confirmation_matcher_helpers.rb +0 -17
  123. data/spec/support/unit/helpers/controller_builder.rb +0 -63
  124. data/spec/support/unit/helpers/database_helpers.rb +0 -20
  125. data/spec/support/unit/helpers/i18n_faker.rb +0 -15
  126. data/spec/support/unit/helpers/mailer_builder.rb +0 -12
  127. data/spec/support/unit/helpers/message_helpers.rb +0 -19
  128. data/spec/support/unit/helpers/model_builder.rb +0 -114
  129. data/spec/support/unit/helpers/rails_versions.rb +0 -42
  130. data/spec/support/unit/helpers/validation_matcher_scenario_helpers.rb +0 -44
  131. data/spec/support/unit/i18n.rb +0 -7
  132. data/spec/support/unit/load_environment.rb +0 -12
  133. data/spec/support/unit/matchers/deprecate.rb +0 -60
  134. data/spec/support/unit/matchers/fail_with_message_including_matcher.rb +0 -51
  135. data/spec/support/unit/matchers/fail_with_message_matcher.rb +0 -64
  136. data/spec/support/unit/matchers/print_warning_including.rb +0 -67
  137. data/spec/support/unit/model_creation_strategies/active_model.rb +0 -111
  138. data/spec/support/unit/model_creation_strategies/active_record.rb +0 -77
  139. data/spec/support/unit/model_creators.rb +0 -19
  140. data/spec/support/unit/model_creators/active_model.rb +0 -39
  141. data/spec/support/unit/model_creators/active_record.rb +0 -42
  142. data/spec/support/unit/model_creators/active_record/has_and_belongs_to_many.rb +0 -95
  143. data/spec/support/unit/model_creators/active_record/has_many.rb +0 -67
  144. data/spec/support/unit/model_creators/active_record/uniqueness_matcher.rb +0 -42
  145. data/spec/support/unit/model_creators/basic.rb +0 -102
  146. data/spec/support/unit/rails_application.rb +0 -151
  147. data/spec/support/unit/record_builder_with_i18n_validation_message.rb +0 -69
  148. data/spec/support/unit/record_validating_confirmation_builder.rb +0 -54
  149. data/spec/support/unit/record_with_different_error_attribute_builder.rb +0 -92
  150. data/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb +0 -79
  151. data/spec/support/unit/shared_examples/numerical_submatcher.rb +0 -17
  152. data/spec/support/unit/shared_examples/set_session_or_flash.rb +0 -360
  153. data/spec/support/unit/validation_matcher_scenario.rb +0 -60
  154. data/spec/unit/shoulda/matchers/action_controller/callback_matcher_spec.rb +0 -82
  155. data/spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +0 -28
  156. data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +0 -629
  157. data/spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +0 -42
  158. data/spec/unit/shoulda/matchers/action_controller/render_template_matcher_spec.rb +0 -76
  159. data/spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +0 -62
  160. data/spec/unit/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +0 -90
  161. data/spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +0 -31
  162. data/spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb +0 -330
  163. data/spec/unit/shoulda/matchers/action_controller/route_params_spec.rb +0 -30
  164. data/spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb +0 -67
  165. data/spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb +0 -17
  166. data/spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb +0 -562
  167. data/spec/unit/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +0 -117
  168. data/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +0 -829
  169. data/spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +0 -86
  170. data/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb +0 -20
  171. data/spec/unit/shoulda/matchers/active_model/helpers_spec.rb +0 -162
  172. data/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +0 -290
  173. data/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +0 -109
  174. data/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +0 -172
  175. data/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +0 -264
  176. data/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +0 -1049
  177. data/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +0 -335
  178. data/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +0 -1865
  179. data/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +0 -406
  180. data/spec/unit/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +0 -107
  181. data/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +0 -1672
  182. data/spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +0 -251
  183. data/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +0 -690
  184. data/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb +0 -111
  185. data/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +0 -85
  186. data/spec/unit/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +0 -41
  187. data/spec/unit/shoulda/matchers/active_record/have_secure_token_matcher_spec.rb +0 -169
  188. data/spec/unit/shoulda/matchers/active_record/serialize_matcher_spec.rb +0 -86
  189. data/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +0 -1682
  190. data/spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb +0 -190
  191. data/spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb +0 -21
  192. data/spec/unit/shoulda/matchers/doublespeak/double_spec.rb +0 -271
  193. data/spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb +0 -77
  194. data/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb +0 -72
  195. data/spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb +0 -101
  196. data/spec/unit/shoulda/matchers/doublespeak/world_spec.rb +0 -78
  197. data/spec/unit/shoulda/matchers/doublespeak_spec.rb +0 -27
  198. data/spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb +0 -43
  199. data/spec/unit/shoulda/matchers/independent/delegate_method_matcher_spec.rb +0 -650
  200. data/spec/unit/shoulda/matchers/routing/route_matcher_spec.rb +0 -406
  201. data/spec/unit/shoulda/matchers/util/word_wrap_spec.rb +0 -252
  202. data/spec/unit_spec_helper.rb +0 -54
  203. data/spec/warnings_spy.rb +0 -64
  204. data/spec/warnings_spy/filesystem.rb +0 -45
  205. data/spec/warnings_spy/partitioner.rb +0 -36
  206. data/spec/warnings_spy/reader.rb +0 -53
  207. data/spec/warnings_spy/reporter.rb +0 -88
  208. data/tasks/documentation.rb +0 -199
  209. data/zeus.json +0 -11
@@ -1,406 +0,0 @@
1
- require 'unit_spec_helper'
2
-
3
- describe 'Shoulda::Matchers::Routing::RouteMatcher', type: :routing do
4
- shared_examples_for 'core tests' do
5
- context 'when the given method, path, controller, and action match an existing route' do
6
- it 'accepts' do
7
- define_controller_and_routes(
8
- method: :get,
9
- path: '/',
10
- controller: 'things',
11
- action: 'index',
12
- )
13
-
14
- matcher = build_route_matcher(
15
- method: :get,
16
- path: '/',
17
- controller: 'things',
18
- action: 'index'
19
- )
20
-
21
- is_expected.to(matcher)
22
- end
23
-
24
- context 'and the expected controller is specified as a symbol' do
25
- it 'accepts' do
26
- define_controller_and_routes(
27
- method: :get,
28
- path: '/',
29
- controller: 'things',
30
- action: 'index',
31
- )
32
-
33
- matcher = build_route_matcher(
34
- method: :get,
35
- path: '/',
36
- controller: :things,
37
- action: 'index'
38
- )
39
-
40
- is_expected.to(matcher)
41
- end
42
- end
43
-
44
- context 'and the expected action is specified as a symbol' do
45
- it 'accepts' do
46
- define_controller_and_routes(
47
- method: :get,
48
- path: '/',
49
- controller: 'things',
50
- action: 'index',
51
- )
52
-
53
- matcher = build_route_matcher(
54
- method: :get,
55
- path: '/',
56
- controller: 'things',
57
- action: :index,
58
- )
59
-
60
- is_expected.to(matcher)
61
- end
62
- end
63
- end
64
-
65
- context 'when the given method, path, controller, and action do not match an existing route' do
66
- it 'rejects' do
67
- matcher = build_route_matcher(
68
- method: :get,
69
- path: '/non_existent_route',
70
- controller: 'some_controller',
71
- action: 'some_action',
72
- )
73
-
74
- is_expected.not_to(matcher)
75
- end
76
- end
77
-
78
- context 'when the given path, controller, and action match an existing route but the method does not' do
79
- it 'rejects' do
80
- define_controller_and_routes(
81
- method: :get,
82
- path: '/',
83
- controller: 'things',
84
- action: 'index',
85
- )
86
-
87
- matcher = build_route_matcher(
88
- method: :post,
89
- path: '/',
90
- controller: 'things',
91
- action: 'index',
92
- )
93
-
94
- is_expected.not_to(matcher)
95
- end
96
- end
97
-
98
- context 'when the given method, controller, and action match an existing route but the path does not' do
99
- it 'rejects' do
100
- define_controller_and_routes(
101
- method: :get,
102
- path: '/',
103
- controller: 'things',
104
- action: 'index',
105
- )
106
-
107
- matcher = build_route_matcher(
108
- method: :get,
109
- path: '/something_else',
110
- controller: 'things',
111
- action: 'index',
112
- )
113
-
114
- is_expected.not_to(matcher)
115
- end
116
- end
117
-
118
- context 'when the given method and path match an existing route but the controller does not' do
119
- it 'rejects' do
120
- define_controller_and_routes(
121
- method: :get,
122
- path: '/',
123
- controller: 'things',
124
- action: 'index',
125
- )
126
-
127
- matcher = build_route_matcher(
128
- method: :get,
129
- path: '/',
130
- controller: 'some_other_controller',
131
- action: 'index',
132
- )
133
-
134
- is_expected.not_to(matcher)
135
- end
136
- end
137
-
138
- context 'when the given method, path, and controller match an existing route but the action does not' do
139
- it 'rejects' do
140
- define_controller_and_routes(
141
- method: :get,
142
- path: '/',
143
- controller: 'things',
144
- action: 'index',
145
- )
146
-
147
- matcher = build_route_matcher(
148
- method: :get,
149
- path: '/',
150
- controller: 'things',
151
- action: 'another_action',
152
- )
153
-
154
- is_expected.not_to(matcher)
155
- end
156
- end
157
-
158
- context 'when the actual route has a param' do
159
- context 'and the expected params include that param' do
160
- it 'accepts' do
161
- define_controller_and_routes(
162
- method: :get,
163
- path: '/things/:id',
164
- controller: 'things',
165
- action: 'show',
166
- )
167
-
168
- matcher = build_route_matcher(
169
- method: :get,
170
- path: '/things/1',
171
- controller: 'things',
172
- action: 'show',
173
- id: '1',
174
- )
175
-
176
- is_expected.to(matcher)
177
- end
178
-
179
- context 'but its value was not specified as a string' do
180
- it 'accepts, treating it as a string' do
181
- define_controller_and_routes(
182
- method: :get,
183
- path: '/things/:id',
184
- controller: 'things',
185
- action: 'show',
186
- )
187
-
188
- matcher = build_route_matcher(
189
- method: :get,
190
- path: '/things/1',
191
- controller: 'things',
192
- action: 'show',
193
- id: 1,
194
- )
195
-
196
- is_expected.to(matcher)
197
- end
198
- end
199
- end
200
-
201
- context 'and the expected params do not match the actual params' do
202
- it 'rejects' do
203
- define_controller_and_routes(
204
- method: :get,
205
- path: '/things/:id',
206
- controller: 'things',
207
- action: 'show',
208
- )
209
-
210
- matcher = build_route_matcher(
211
- method: :get,
212
- path: '/things/1',
213
- controller: 'things',
214
- action: 'show',
215
- some: 'other',
216
- params: 'here',
217
- )
218
-
219
- is_expected.not_to(matcher)
220
- end
221
- end
222
- end
223
-
224
- context 'when the actual route has a default param whose value is a symbol' do
225
- context 'and the expected params include a value for it' do
226
- context 'as a symbol' do
227
- it 'accepts' do
228
- define_controller_and_routes(
229
- method: :post,
230
- path: '/things(.:format)',
231
- controller: 'things',
232
- action: 'create',
233
- defaults: { format: :json },
234
- )
235
-
236
- matcher = build_route_matcher(
237
- method: :post,
238
- path: '/things',
239
- controller: 'things',
240
- action: 'create',
241
- format: :json,
242
- )
243
-
244
- is_expected.to(matcher)
245
- end
246
- end
247
-
248
- context 'as a string' do
249
- it 'accepts' do
250
- define_controller_and_routes(
251
- method: :post,
252
- path: '/things(.:format)',
253
- controller: 'things',
254
- action: 'create',
255
- defaults: { format: :json },
256
- )
257
-
258
- matcher = build_route_matcher(
259
- method: :post,
260
- path: '/things',
261
- controller: 'things',
262
- action: 'create',
263
- format: 'json',
264
- )
265
-
266
- is_expected.to(matcher)
267
- end
268
- end
269
- end
270
- end
271
-
272
- context 'when the existing route has a glob segment' do
273
- context 'and a param is given which represents the segment' do
274
- it 'accepts' do
275
- define_controller_and_routes(
276
- method: :get,
277
- path: '/things/*id',
278
- controller: 'things',
279
- action: 'show',
280
- )
281
-
282
- matcher = build_route_matcher(
283
- method: :get,
284
- path: '/things/foo/bar',
285
- controller: 'things',
286
- action: 'show',
287
- id: 'foo/bar',
288
- )
289
-
290
- is_expected.to(matcher)
291
- end
292
- end
293
-
294
- context 'and no param is given which represents the segment' do
295
- it 'rejects' do
296
- define_controller_and_routes(
297
- method: :get,
298
- path: '/things/*id',
299
- controller: 'things',
300
- action: 'show',
301
- )
302
-
303
- matcher = build_route_matcher(
304
- method: :get,
305
- path: '/things',
306
- controller: 'things',
307
- action: 'show',
308
- )
309
-
310
- is_expected.not_to(matcher)
311
- end
312
- end
313
- end
314
-
315
- context 'when a port is specified' do
316
- context 'when the route is constrained to the same port' do
317
- it 'accepts' do
318
- define_controller_and_routes(
319
- method: :get,
320
- path: '/',
321
- controller: 'things',
322
- action: 'show',
323
- constraints: port_constraint_class.new(12345),
324
- )
325
-
326
- matcher = build_route_matcher(
327
- method: :get,
328
- path: '/',
329
- controller: 'things',
330
- action: 'show',
331
- port: 12345,
332
- )
333
-
334
- is_expected.to(matcher)
335
- end
336
- end
337
-
338
- context 'when the route is not constrained to the same port' do
339
- it 'rejects' do
340
- define_controller_and_routes(
341
- method: :get,
342
- path: '/',
343
- controller: 'things',
344
- action: 'show',
345
- constraints: port_constraint_class.new(12345),
346
- )
347
-
348
- matcher = build_route_matcher(
349
- method: :get,
350
- path: '/',
351
- controller: 'things',
352
- action: 'show',
353
- port: 99999,
354
- )
355
-
356
- is_expected.not_to(matcher)
357
- end
358
- end
359
- end
360
- end
361
-
362
- context 'given a controller and action specified as individual options' do
363
- include_examples 'core tests' do
364
- def build_route_matcher(method:, path:, port: nil, **params)
365
- super(method: method, path: path, port: port).to(params)
366
- end
367
- end
368
- end
369
-
370
- context 'given a controller and action joined together in a string' do
371
- include_examples 'core tests' do
372
- def build_route_matcher(method:, path:, controller:, action:, port: nil, **rest)
373
- super(method: method, path: path, port: port).
374
- to("#{controller}##{action}", **rest)
375
- end
376
- end
377
- end
378
-
379
- def define_controller_and_routes(method:, path:, controller:, action:, **params)
380
- define_controller(controller.camelize)
381
-
382
- define_routes do
383
- send(method, path, controller: controller, action: action, **params)
384
- end
385
- end
386
-
387
- def build_route_matcher(method:, path:, port:, **)
388
- route(method, path, port: port)
389
- end
390
-
391
- let(:port_constraint_class) do
392
- Class.new do
393
- def initialize(port)
394
- @port = port
395
- end
396
-
397
- def matches?(request)
398
- request.port == port
399
- end
400
-
401
- private
402
-
403
- attr_reader :port
404
- end
405
- end
406
- end
@@ -1,252 +0,0 @@
1
- require 'spec_helper'
2
- require 'shoulda/matchers/util/word_wrap'
3
-
4
- describe Shoulda::Matchers, ".word_wrap" do
5
- it "can wrap a simple paragraph" do
6
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
7
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat
8
- MESSAGE
9
-
10
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
11
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus,
12
- ipsum sit amet efficitur feugiat
13
- MESSAGE
14
- end
15
-
16
- it "does not split words up when wrapping" do
17
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
18
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean lusciousness, ipsum sit amet efficitur feugiat
19
- MESSAGE
20
-
21
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
22
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
23
- lusciousness, ipsum sit amet efficitur feugiat
24
- MESSAGE
25
- end
26
-
27
- it "considers punctuation as part of a word" do
28
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
29
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscious, ipsum sit amet efficitur feugiat
30
- MESSAGE
31
-
32
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
33
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
34
- luscious, ipsum sit amet efficitur feugiat
35
- MESSAGE
36
- end
37
-
38
- it "does not break at the maximum line length, but afterward" do
39
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
40
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscius, ipsum sit amet efficitur feugiat
41
- MESSAGE
42
-
43
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
44
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscius,
45
- ipsum sit amet efficitur feugiat
46
- MESSAGE
47
- end
48
-
49
- it "re-wraps entire paragraphs" do
50
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
51
- Lorem ipsum dolor sit amet,
52
- consectetur adipiscing elit.
53
- Aenean luctus,
54
- ipsum sit amet efficitur feugiat,
55
- dolor mauris fringilla erat, sed posuere diam ex ut velit.
56
- MESSAGE
57
-
58
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
59
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus,
60
- ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed
61
- posuere diam ex ut velit.
62
- MESSAGE
63
- end
64
-
65
- it "can wrap multiple paragraphs" do
66
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
67
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
68
-
69
- Etiam ultrices cursus ligula eget feugiat. Vestibulum eget tincidunt risus, non faucibus sem.
70
- MESSAGE
71
-
72
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
73
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus,
74
- ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed
75
- posuere diam ex ut velit.
76
-
77
- Etiam ultrices cursus ligula eget feugiat. Vestibulum eget tincidunt
78
- risus, non faucibus sem.
79
- MESSAGE
80
- end
81
-
82
- it "can wrap a bulleted list" do
83
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
84
- * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
85
- * And the beat goes on.
86
- MESSAGE
87
-
88
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
89
- * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
90
- luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat,
91
- sed posuere diam ex ut velit.
92
- * And the beat goes on.
93
- MESSAGE
94
- end
95
-
96
- it "re-wraps bulleted lists" do
97
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
98
- * Lorem ipsum dolor sit amet,
99
- consectetur adipiscing elit.
100
- Aenean luctus,
101
- ipsum sit amet efficitur feugiat,
102
- dolor mauris fringilla erat,
103
- sed posuere diam ex ut velit.
104
- * And the beat goes on.
105
- MESSAGE
106
-
107
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
108
- * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
109
- luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat,
110
- sed posuere diam ex ut velit.
111
- * And the beat goes on.
112
- MESSAGE
113
- end
114
-
115
- it "can wrap a numbered list" do
116
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
117
- 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
118
- 2. And the beat goes on.
119
- MESSAGE
120
-
121
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
122
- 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
123
- luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla
124
- erat, sed posuere diam ex ut velit.
125
- 2. And the beat goes on.
126
- MESSAGE
127
- end
128
-
129
- it "re-wraps numbered lists" do
130
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
131
- 1. Lorem ipsum dolor sit amet,
132
- consectetur adipiscing elit.
133
- Aenean luctus,
134
- ipsum sit amet efficitur feugiat,
135
- dolor mauris fringilla erat,
136
- sed posuere diam ex ut velit.
137
- 2. And the beat goes on.
138
- MESSAGE
139
-
140
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
141
- 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
142
- luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla
143
- erat, sed posuere diam ex ut velit.
144
- 2. And the beat goes on.
145
- MESSAGE
146
- end
147
-
148
- it "can wrap a numbered list, using x) instead of x. as the leader" do
149
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
150
- 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
151
- 2) And the beat goes on.
152
- MESSAGE
153
-
154
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
155
- 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
156
- luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla
157
- erat, sed posuere diam ex ut velit.
158
- 2) And the beat goes on.
159
- MESSAGE
160
- end
161
-
162
- it "re-wraps numbered lists using x) instead of x. as the leader" do
163
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
164
- 1) Lorem ipsum dolor sit amet,
165
- consectetur adipiscing elit.
166
- Aenean luctus,
167
- ipsum sit amet efficitur feugiat,
168
- dolor mauris fringilla erat,
169
- sed posuere diam ex ut velit.
170
- 2) And the beat goes on.
171
- MESSAGE
172
-
173
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
174
- 1) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
175
- luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla
176
- erat, sed posuere diam ex ut velit.
177
- 2) And the beat goes on.
178
- MESSAGE
179
- end
180
-
181
- it "doesn't mess with indented blocks" do
182
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
183
- Some text is gonna go here.
184
-
185
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
186
-
187
- And now we return.
188
- MESSAGE
189
-
190
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
191
- Some text is gonna go here.
192
-
193
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
194
-
195
- And now we return.
196
- MESSAGE
197
- end
198
-
199
- context "given a string with a word longer than the max character limit" do
200
- context "which stands on its own" do
201
- it "simply returns the string" do
202
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
203
- Foo bar baz and stuff and things Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
204
- MESSAGE
205
-
206
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
207
- Foo bar baz and stuff and things
208
- Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
209
- MESSAGE
210
- end
211
- end
212
-
213
- context "which is preceded by some text" do
214
- it "leaves the word on its own line" do
215
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
216
- Foo bar baz and stuff and things Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
217
- MESSAGE
218
-
219
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
220
- Foo bar baz and stuff and things
221
- Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
222
- MESSAGE
223
- end
224
- end
225
-
226
- context "which is followed by some text" do
227
- it "leaves the word on its own line" do
228
- wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
229
- Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat, and something goes after this
230
- MESSAGE
231
-
232
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
233
- Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
234
- and something goes after this
235
- MESSAGE
236
- end
237
- end
238
- end
239
-
240
- context "when :indent is given" do
241
- it "uses the given indentation level when determining where to wrap lines" do
242
- wrapped_message = described_class.word_wrap(<<-MESSAGE.strip, indent: 2)
243
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat
244
- MESSAGE
245
-
246
- expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
247
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
248
- luctus, ipsum sit amet efficitur feugiat
249
- MESSAGE
250
- end
251
- end
252
- end