motion-kit 0.0.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +839 -0
  3. data/lib/motion-kit-cocoa/cocoa_util.rb +59 -0
  4. data/lib/motion-kit-cocoa/constraints/constraint.rb +765 -0
  5. data/lib/motion-kit-cocoa/constraints/constraint_placeholder.rb +22 -0
  6. data/lib/motion-kit-cocoa/constraints/constraints_layout.rb +536 -0
  7. data/lib/motion-kit-cocoa/constraints/constraints_target.rb +52 -0
  8. data/lib/motion-kit-cocoa/layouts/cagradientlayer_layout.rb +13 -0
  9. data/lib/motion-kit-cocoa/layouts/calayer_layout.rb +27 -0
  10. data/lib/motion-kit-cocoa/layouts/sugarcube_compat.rb +38 -0
  11. data/lib/motion-kit-ios/dummy.rb +93 -0
  12. data/lib/motion-kit-ios/ios_util.rb +20 -0
  13. data/lib/motion-kit-ios/layouts/constraints_layout.rb +22 -0
  14. data/lib/motion-kit-ios/layouts/layout_device.rb +32 -0
  15. data/lib/motion-kit-ios/layouts/layout_orientation.rb +47 -0
  16. data/lib/motion-kit-ios/layouts/uibutton_layout.rb +52 -0
  17. data/lib/motion-kit-ios/layouts/uiview_layout.rb +45 -0
  18. data/lib/motion-kit-ios/layouts/uiview_layout_autoresizing.rb +75 -0
  19. data/lib/motion-kit-ios/layouts/uiview_layout_constraints.rb +36 -0
  20. data/lib/motion-kit-ios/layouts/uiview_layout_frame.rb +307 -0
  21. data/lib/motion-kit-ios/layouts/uiview_layout_gradient.rb +20 -0
  22. data/lib/motion-kit-osx/dummy.rb +89 -0
  23. data/lib/motion-kit-osx/layouts/constraints_layout.rb +42 -0
  24. data/lib/motion-kit-osx/layouts/nsmenu_extensions.rb +186 -0
  25. data/lib/motion-kit-osx/layouts/nsmenu_layout.rb +109 -0
  26. data/lib/motion-kit-osx/layouts/nsmenuitem_extensions.rb +45 -0
  27. data/lib/motion-kit-osx/layouts/nstablecolumn_layout.rb +12 -0
  28. data/lib/motion-kit-osx/layouts/nstableview_layout.rb +20 -0
  29. data/lib/motion-kit-osx/layouts/nsview_layout.rb +47 -0
  30. data/lib/motion-kit-osx/layouts/nsview_layout_autoresizing.rb +75 -0
  31. data/lib/motion-kit-osx/layouts/nsview_layout_constraints.rb +34 -0
  32. data/lib/motion-kit-osx/layouts/nsview_layout_frame.rb +375 -0
  33. data/lib/motion-kit-osx/layouts/nswindow_frame.rb +14 -0
  34. data/lib/motion-kit-osx/layouts/nswindow_layout.rb +77 -0
  35. data/lib/motion-kit-osx/osx_util.rb +16 -0
  36. data/lib/motion-kit.rb +33 -0
  37. data/lib/motion-kit/calculate.rb +263 -0
  38. data/lib/motion-kit/layouts/base_layout.rb +299 -0
  39. data/lib/motion-kit/layouts/base_layout_class_methods.rb +43 -0
  40. data/lib/motion-kit/layouts/parent.rb +68 -0
  41. data/lib/motion-kit/layouts/view_layout.rb +327 -0
  42. data/lib/motion-kit/motion-kit.rb +18 -0
  43. data/lib/motion-kit/object.rb +16 -0
  44. data/lib/motion-kit/util.rb +20 -0
  45. data/lib/motion-kit/version.rb +1 -1
  46. data/spec/ios/apply_styles_spec.rb +21 -0
  47. data/spec/ios/autoresizing_helper_spec.rb +224 -0
  48. data/spec/ios/calculate_spec.rb +322 -0
  49. data/spec/ios/calculator_spec.rb +31 -0
  50. data/spec/ios/constraints_helpers/attribute_lookup_spec.rb +27 -0
  51. data/spec/ios/constraints_helpers/axis_lookup_spec.rb +13 -0
  52. data/spec/ios/constraints_helpers/center_constraints_spec.rb +419 -0
  53. data/spec/ios/constraints_helpers/constraint_placeholder_spec.rb +72 -0
  54. data/spec/ios/constraints_helpers/priority_lookup_spec.rb +19 -0
  55. data/spec/ios/constraints_helpers/relationship_lookup_spec.rb +27 -0
  56. data/spec/ios/constraints_helpers/relative_corners_spec.rb +274 -0
  57. data/spec/ios/constraints_helpers/relative_location_spec.rb +111 -0
  58. data/spec/ios/constraints_helpers/simple_constraints_spec.rb +2763 -0
  59. data/spec/ios/constraints_helpers/size_constraints_spec.rb +422 -0
  60. data/spec/ios/constraints_helpers/view_lookup_constraints_spec.rb +93 -0
  61. data/spec/ios/create_layout_spec.rb +40 -0
  62. data/spec/ios/custom_layout_spec.rb +13 -0
  63. data/spec/ios/deferred_spec.rb +89 -0
  64. data/spec/ios/device_helpers_spec.rb +51 -0
  65. data/spec/ios/frame_helper_spec.rb +1150 -0
  66. data/spec/ios/layer_layout_spec.rb +36 -0
  67. data/spec/ios/layout_extensions_spec.rb +70 -0
  68. data/spec/ios/layout_spec.rb +74 -0
  69. data/spec/ios/layout_state_spec.rb +27 -0
  70. data/spec/ios/motionkit_util_spec.rb +102 -0
  71. data/spec/ios/objc_selectors_spec.rb +10 -0
  72. data/spec/ios/orientation_helper_specs.rb +67 -0
  73. data/spec/ios/parent_layout_spec.rb +19 -0
  74. data/spec/ios/parent_spec.rb +45 -0
  75. data/spec/ios/remove_layout_spec.rb +25 -0
  76. data/spec/ios/root_layout_spec.rb +53 -0
  77. data/spec/ios/setters_spec.rb +63 -0
  78. data/spec/ios/uibutton_layout_spec.rb +24 -0
  79. data/spec/ios/uitextfield_spec.rb +14 -0
  80. data/spec/ios/view_attr_spec.rb +25 -0
  81. data/spec/osx/autoresizing_helper_spec.rb +224 -0
  82. data/spec/osx/constraints_helper_spec.rb +0 -0
  83. data/spec/osx/constraints_helpers/orientation_lookup_spec.rb +13 -0
  84. data/spec/osx/constraints_helpers/simple_constraints_spec.rb +2095 -0
  85. data/spec/osx/constraints_helpers/size_constraints_spec.rb +362 -0
  86. data/spec/osx/create_menu_spec.rb +14 -0
  87. data/spec/osx/create_via_extensions_spec.rb +63 -0
  88. data/spec/osx/deferred_spec.rb +85 -0
  89. data/spec/osx/frame_helper_spec.rb +1881 -0
  90. data/spec/osx/menu_extensions_spec.rb +376 -0
  91. data/spec/osx/menu_layout_spec.rb +157 -0
  92. data/spec/osx/menu_spec.rb +70 -0
  93. data/spec/osx/root_menu_spec.rb +15 -0
  94. metadata +166 -14
@@ -0,0 +1,2095 @@
1
+ describe 'Constraints helpers' do
2
+
3
+ before do
4
+ @layout = MK::Layout.new
5
+ @constraint = nil
6
+ end
7
+
8
+ describe '`x/left` support' do
9
+ it 'should support `x 10`' do
10
+ @layout.context(NSView.new) do
11
+ @layout.constraints do
12
+ @constraint = @layout.x(10)
13
+ end
14
+ end
15
+ @constraint.constant.should == 10
16
+ @constraint.relationship.should == :equal
17
+ @constraint.multiplier.should == 1
18
+ @constraint.relative_to.should == :superview
19
+ @constraint.attribute.should == :left
20
+ @constraint.attribute2.should == :left
21
+ end
22
+ it 'should support `min_x 10`' do
23
+ @layout.context(NSView.new) do
24
+ @layout.constraints do
25
+ @constraint = @layout.min_x(10)
26
+ end
27
+ end
28
+ @constraint.constant.should == 10
29
+ @constraint.relationship.should == :gte
30
+ @constraint.multiplier.should == 1
31
+ @constraint.relative_to.should == :superview
32
+ @constraint.attribute.should == :left
33
+ @constraint.attribute2.should == :left
34
+ end
35
+ it 'should support `max_x 10`' do
36
+ @layout.context(NSView.new) do
37
+ @layout.constraints do
38
+ @constraint = @layout.max_x(10)
39
+ end
40
+ end
41
+ @constraint.constant.should == 10
42
+ @constraint.relationship.should == :lte
43
+ @constraint.multiplier.should == 1
44
+ @constraint.relative_to.should == :superview
45
+ @constraint.attribute.should == :left
46
+ @constraint.attribute2.should == :left
47
+ end
48
+ it 'should support `x.equals(:another_view[, :left])`' do
49
+ @layout.context(NSView.new) do
50
+ @layout.constraints do
51
+ @constraint = @layout.x.equals(:another_view)
52
+ end
53
+ end
54
+ @constraint.constant.should == 0
55
+ @constraint.relationship.should == :equal
56
+ @constraint.multiplier.should == 1
57
+ @constraint.relative_to.should == :another_view
58
+ @constraint.attribute.should == :left
59
+ @constraint.attribute2.should == :left
60
+ end
61
+ it 'should support `x.equals(:another_view).plus(10)`' do
62
+ @layout.context(NSView.new) do
63
+ @layout.constraints do
64
+ @constraint = @layout.x.equals(:another_view).plus(10)
65
+ end
66
+ end
67
+ @constraint.constant.should == 10
68
+ @constraint.relationship.should == :equal
69
+ @constraint.multiplier.should == 1
70
+ @constraint.relative_to.should == :another_view
71
+ @constraint.attribute.should == :left
72
+ @constraint.attribute2.should == :left
73
+ end
74
+ it 'should support `x.equals(:another_view).plus(10).plus(20)`' do
75
+ @layout.context(NSView.new) do
76
+ @layout.constraints do
77
+ @constraint = @layout.x.equals(:another_view).plus(10).plus(20)
78
+ end
79
+ end
80
+ @constraint.constant.should == 30
81
+ @constraint.relationship.should == :equal
82
+ @constraint.multiplier.should == 1
83
+ @constraint.relative_to.should == :another_view
84
+ @constraint.attribute.should == :left
85
+ @constraint.attribute2.should == :left
86
+ end
87
+ it 'should support `min_x.equals(:another_view[, :left])`' do
88
+ @layout.context(NSView.new) do
89
+ @layout.constraints do
90
+ @constraint = @layout.min_x.equals(:another_view)
91
+ end
92
+ end
93
+ @constraint.constant.should == 0
94
+ @constraint.relationship.should == :gte
95
+ @constraint.multiplier.should == 1
96
+ @constraint.relative_to.should == :another_view
97
+ @constraint.attribute.should == :left
98
+ @constraint.attribute2.should == :left
99
+ end
100
+ it 'should support `max_x.equals(:another_view[, :left])`' do
101
+ @layout.context(NSView.new) do
102
+ @layout.constraints do
103
+ @constraint = @layout.max_x.equals(:another_view)
104
+ end
105
+ end
106
+ @constraint.constant.should == 0
107
+ @constraint.relationship.should == :lte
108
+ @constraint.multiplier.should == 1
109
+ @constraint.relative_to.should == :another_view
110
+ @constraint.attribute.should == :left
111
+ @constraint.attribute2.should == :left
112
+ end
113
+ it 'should support `x.equals(:another_view, :right)`' do
114
+ @layout.context(NSView.new) do
115
+ @layout.constraints do
116
+ @constraint = @layout.x.equals(:another_view, :right)
117
+ end
118
+ end
119
+ @constraint.constant.should == 0
120
+ @constraint.relationship.should == :equal
121
+ @constraint.multiplier.should == 1
122
+ @constraint.relative_to.should == :another_view
123
+ @constraint.attribute.should == :left
124
+ @constraint.attribute2.should == :right
125
+ end
126
+ it 'should support `min_x.equals(:another_view, :right)`' do
127
+ @layout.context(NSView.new) do
128
+ @layout.constraints do
129
+ @constraint = @layout.min_x.equals(:another_view, :right)
130
+ end
131
+ end
132
+ @constraint.constant.should == 0
133
+ @constraint.relationship.should == :gte
134
+ @constraint.multiplier.should == 1
135
+ @constraint.relative_to.should == :another_view
136
+ @constraint.attribute.should == :left
137
+ @constraint.attribute2.should == :right
138
+ end
139
+ it 'should support `max_x.equals(:another_view, :right)`' do
140
+ @layout.context(NSView.new) do
141
+ @layout.constraints do
142
+ @constraint = @layout.max_x.equals(:another_view, :right)
143
+ end
144
+ end
145
+ @constraint.constant.should == 0
146
+ @constraint.relationship.should == :lte
147
+ @constraint.multiplier.should == 1
148
+ @constraint.relative_to.should == :another_view
149
+ @constraint.attribute.should == :left
150
+ @constraint.attribute2.should == :right
151
+ end
152
+ it 'should support `x.equals(:another_view, :right).minus(10)`' do
153
+ @layout.context(NSView.new) do
154
+ @layout.constraints do
155
+ @constraint = @layout.x.equals(:another_view, :right).minus(10)
156
+ end
157
+ end
158
+ @constraint.constant.should == -10
159
+ @constraint.relationship.should == :equal
160
+ @constraint.multiplier.should == 1
161
+ @constraint.relative_to.should == :another_view
162
+ @constraint.attribute.should == :left
163
+ @constraint.attribute2.should == :right
164
+ end
165
+ it 'should support `min_x.equals(:another_view, :right).plus(10)`' do
166
+ @layout.context(NSView.new) do
167
+ @layout.constraints do
168
+ @constraint = @layout.min_x.equals(:another_view, :right).plus(10)
169
+ end
170
+ end
171
+ @constraint.constant.should == 10
172
+ @constraint.relationship.should == :gte
173
+ @constraint.multiplier.should == 1
174
+ @constraint.relative_to.should == :another_view
175
+ @constraint.attribute.should == :left
176
+ @constraint.attribute2.should == :right
177
+ end
178
+ it 'should support `max_x.equals(:another_view, :right).plus(10)`' do
179
+ @layout.context(NSView.new) do
180
+ @layout.constraints do
181
+ @constraint = @layout.max_x.equals(:another_view, :right).plus(10)
182
+ end
183
+ end
184
+ @constraint.constant.should == 10
185
+ @constraint.relationship.should == :lte
186
+ @constraint.multiplier.should == 1
187
+ @constraint.relative_to.should == :another_view
188
+ @constraint.attribute.should == :left
189
+ @constraint.attribute2.should == :right
190
+ end
191
+ it 'should support `x.equals(:another_view).times(2).plus(10)`' do
192
+ @layout.context(NSView.new) do
193
+ @layout.constraints do
194
+ @constraint = @layout.x.equals(:another_view).times(2).plus(10)
195
+ end
196
+ end
197
+ @constraint.constant.should == 10
198
+ @constraint.relationship.should == :equal
199
+ @constraint.multiplier.should == 2
200
+ @constraint.relative_to.should == :another_view
201
+ @constraint.attribute.should == :left
202
+ @constraint.attribute2.should == :left
203
+ end
204
+ it 'should support `min_x.equals(:another_view).times(2).plus(10)`' do
205
+ @layout.context(NSView.new) do
206
+ @layout.constraints do
207
+ @constraint = @layout.min_x.equals(:another_view).times(2).plus(10)
208
+ end
209
+ end
210
+ @constraint.constant.should == 10
211
+ @constraint.relationship.should == :gte
212
+ @constraint.multiplier.should == 2
213
+ @constraint.relative_to.should == :another_view
214
+ @constraint.attribute.should == :left
215
+ @constraint.attribute2.should == :left
216
+ end
217
+ it 'should support `max_x.equals(:another_view).times(2).plus(10)`' do
218
+ @layout.context(NSView.new) do
219
+ @layout.constraints do
220
+ @constraint = @layout.max_x.equals(:another_view).times(2).plus(10)
221
+ end
222
+ end
223
+ @constraint.constant.should == 10
224
+ @constraint.relationship.should == :lte
225
+ @constraint.multiplier.should == 2
226
+ @constraint.relative_to.should == :another_view
227
+ @constraint.attribute.should == :left
228
+ @constraint.attribute2.should == :left
229
+ end
230
+ it 'should support `left.equals(:another_view).times(2).plus(10)`' do
231
+ @layout.context(NSView.new) do
232
+ @layout.constraints do
233
+ @constraint = @layout.left.equals(:another_view).times(2).plus(10)
234
+ end
235
+ end
236
+ @constraint.constant.should == 10
237
+ @constraint.relationship.should == :equal
238
+ @constraint.multiplier.should == 2
239
+ @constraint.relative_to.should == :another_view
240
+ @constraint.attribute.should == :left
241
+ @constraint.attribute2.should == :left
242
+ end
243
+ it 'should support `min_left.equals(:another_view).times(2).plus(10)`' do
244
+ @layout.context(NSView.new) do
245
+ @layout.constraints do
246
+ @constraint = @layout.min_left.equals(:another_view).times(2).plus(10)
247
+ end
248
+ end
249
+ @constraint.constant.should == 10
250
+ @constraint.relationship.should == :gte
251
+ @constraint.multiplier.should == 2
252
+ @constraint.relative_to.should == :another_view
253
+ @constraint.attribute.should == :left
254
+ @constraint.attribute2.should == :left
255
+ end
256
+ it 'should support `max_left.equals(:another_view).times(2).plus(10)`' do
257
+ @layout.context(NSView.new) do
258
+ @layout.constraints do
259
+ @constraint = @layout.max_left.equals(:another_view).times(2).plus(10)
260
+ end
261
+ end
262
+ @constraint.constant.should == 10
263
+ @constraint.relationship.should == :lte
264
+ @constraint.multiplier.should == 2
265
+ @constraint.relative_to.should == :another_view
266
+ @constraint.attribute.should == :left
267
+ @constraint.attribute2.should == :left
268
+ end
269
+ end
270
+
271
+ describe '`center_x` support' do
272
+ it 'should support `center_x 10`' do
273
+ @layout.context(NSView.new) do
274
+ @layout.constraints do
275
+ @constraint = @layout.center_x(10)
276
+ end
277
+ end
278
+ @constraint.constant.should == 10
279
+ @constraint.relationship.should == :equal
280
+ @constraint.multiplier.should == 1
281
+ @constraint.relative_to.should == :superview
282
+ @constraint.attribute.should == :center_x
283
+ @constraint.attribute2.should == :center_x
284
+ end
285
+ it 'should support `min_center_x 10`' do
286
+ @layout.context(NSView.new) do
287
+ @layout.constraints do
288
+ @constraint = @layout.min_center_x(10)
289
+ end
290
+ end
291
+ @constraint.constant.should == 10
292
+ @constraint.relationship.should == :gte
293
+ @constraint.multiplier.should == 1
294
+ @constraint.relative_to.should == :superview
295
+ @constraint.attribute.should == :center_x
296
+ @constraint.attribute2.should == :center_x
297
+ end
298
+ it 'should support `max_center_x 10`' do
299
+ @layout.context(NSView.new) do
300
+ @layout.constraints do
301
+ @constraint = @layout.max_center_x(10)
302
+ end
303
+ end
304
+ @constraint.constant.should == 10
305
+ @constraint.relationship.should == :lte
306
+ @constraint.multiplier.should == 1
307
+ @constraint.relative_to.should == :superview
308
+ @constraint.attribute.should == :center_x
309
+ @constraint.attribute2.should == :center_x
310
+ end
311
+ it 'should support `center_x.equals(:another_view[, :center_x])`' do
312
+ @layout.context(NSView.new) do
313
+ @layout.constraints do
314
+ @constraint = @layout.center_x.equals(:another_view)
315
+ end
316
+ end
317
+ @constraint.constant.should == 0
318
+ @constraint.relationship.should == :equal
319
+ @constraint.multiplier.should == 1
320
+ @constraint.relative_to.should == :another_view
321
+ @constraint.attribute.should == :center_x
322
+ @constraint.attribute2.should == :center_x
323
+ end
324
+ it 'should support `min_center_x.equals(:another_view[, :center_x])`' do
325
+ @layout.context(NSView.new) do
326
+ @layout.constraints do
327
+ @constraint = @layout.min_center_x.equals(:another_view)
328
+ end
329
+ end
330
+ @constraint.constant.should == 0
331
+ @constraint.relationship.should == :gte
332
+ @constraint.multiplier.should == 1
333
+ @constraint.relative_to.should == :another_view
334
+ @constraint.attribute.should == :center_x
335
+ @constraint.attribute2.should == :center_x
336
+ end
337
+ it 'should support `max_center_x.equals(:another_view[, :center_x])`' do
338
+ @layout.context(NSView.new) do
339
+ @layout.constraints do
340
+ @constraint = @layout.max_center_x.equals(:another_view)
341
+ end
342
+ end
343
+ @constraint.constant.should == 0
344
+ @constraint.relationship.should == :lte
345
+ @constraint.multiplier.should == 1
346
+ @constraint.relative_to.should == :another_view
347
+ @constraint.attribute.should == :center_x
348
+ @constraint.attribute2.should == :center_x
349
+ end
350
+ it 'should support `center_x.equals(:another_view, :right)`' do
351
+ @layout.context(NSView.new) do
352
+ @layout.constraints do
353
+ @constraint = @layout.center_x.equals(:another_view, :right)
354
+ end
355
+ end
356
+ @constraint.constant.should == 0
357
+ @constraint.relationship.should == :equal
358
+ @constraint.multiplier.should == 1
359
+ @constraint.relative_to.should == :another_view
360
+ @constraint.attribute.should == :center_x
361
+ @constraint.attribute2.should == :right
362
+ end
363
+ it 'should support `min_center_x.equals(:another_view, :right)`' do
364
+ @layout.context(NSView.new) do
365
+ @layout.constraints do
366
+ @constraint = @layout.min_center_x.equals(:another_view, :right)
367
+ end
368
+ end
369
+ @constraint.constant.should == 0
370
+ @constraint.relationship.should == :gte
371
+ @constraint.multiplier.should == 1
372
+ @constraint.relative_to.should == :another_view
373
+ @constraint.attribute.should == :center_x
374
+ @constraint.attribute2.should == :right
375
+ end
376
+ it 'should support `max_center_x.equals(:another_view, :right)`' do
377
+ @layout.context(NSView.new) do
378
+ @layout.constraints do
379
+ @constraint = @layout.max_center_x.equals(:another_view, :right)
380
+ end
381
+ end
382
+ @constraint.constant.should == 0
383
+ @constraint.relationship.should == :lte
384
+ @constraint.multiplier.should == 1
385
+ @constraint.relative_to.should == :another_view
386
+ @constraint.attribute.should == :center_x
387
+ @constraint.attribute2.should == :right
388
+ end
389
+ it 'should support `center_x.equals(:another_view, :right).plus(10)`' do
390
+ @layout.context(NSView.new) do
391
+ @layout.constraints do
392
+ @constraint = @layout.center_x.equals(:another_view, :right).plus(10)
393
+ end
394
+ end
395
+ @constraint.constant.should == 10
396
+ @constraint.relationship.should == :equal
397
+ @constraint.multiplier.should == 1
398
+ @constraint.relative_to.should == :another_view
399
+ @constraint.attribute.should == :center_x
400
+ @constraint.attribute2.should == :right
401
+ end
402
+ it 'should support `min_center_x.equals(:another_view, :right).plus(10)`' do
403
+ @layout.context(NSView.new) do
404
+ @layout.constraints do
405
+ @constraint = @layout.min_center_x.equals(:another_view, :right).plus(10)
406
+ end
407
+ end
408
+ @constraint.constant.should == 10
409
+ @constraint.relationship.should == :gte
410
+ @constraint.multiplier.should == 1
411
+ @constraint.relative_to.should == :another_view
412
+ @constraint.attribute.should == :center_x
413
+ @constraint.attribute2.should == :right
414
+ end
415
+ it 'should support `max_center_x.equals(:another_view, :right).plus(10)`' do
416
+ @layout.context(NSView.new) do
417
+ @layout.constraints do
418
+ @constraint = @layout.max_center_x.equals(:another_view, :right).plus(10)
419
+ end
420
+ end
421
+ @constraint.constant.should == 10
422
+ @constraint.relationship.should == :lte
423
+ @constraint.multiplier.should == 1
424
+ @constraint.relative_to.should == :another_view
425
+ @constraint.attribute.should == :center_x
426
+ @constraint.attribute2.should == :right
427
+ end
428
+ it 'should support `center_x.equals(:another_view).times(2).plus(10)`' do
429
+ @layout.context(NSView.new) do
430
+ @layout.constraints do
431
+ @constraint = @layout.center_x.equals(:another_view).times(2).plus(10)
432
+ end
433
+ end
434
+ @constraint.constant.should == 10
435
+ @constraint.relationship.should == :equal
436
+ @constraint.multiplier.should == 2
437
+ @constraint.relative_to.should == :another_view
438
+ @constraint.attribute.should == :center_x
439
+ @constraint.attribute2.should == :center_x
440
+ end
441
+ it 'should support `min_center_x.equals(:another_view).times(2).plus(10)`' do
442
+ @layout.context(NSView.new) do
443
+ @layout.constraints do
444
+ @constraint = @layout.min_center_x.equals(:another_view).times(2).plus(10)
445
+ end
446
+ end
447
+ @constraint.constant.should == 10
448
+ @constraint.relationship.should == :gte
449
+ @constraint.multiplier.should == 2
450
+ @constraint.relative_to.should == :another_view
451
+ @constraint.attribute.should == :center_x
452
+ @constraint.attribute2.should == :center_x
453
+ end
454
+ it 'should support `max_center_x.equals(:another_view).times(2).plus(10)`' do
455
+ @layout.context(NSView.new) do
456
+ @layout.constraints do
457
+ @constraint = @layout.max_center_x.equals(:another_view).times(2).plus(10)
458
+ end
459
+ end
460
+ @constraint.constant.should == 10
461
+ @constraint.relationship.should == :lte
462
+ @constraint.multiplier.should == 2
463
+ @constraint.relative_to.should == :another_view
464
+ @constraint.attribute.should == :center_x
465
+ @constraint.attribute2.should == :center_x
466
+ end
467
+ end
468
+
469
+ describe '`right` support' do
470
+ it 'should support `right 10`' do
471
+ @layout.context(NSView.new) do
472
+ @layout.constraints do
473
+ @constraint = @layout.right(10)
474
+ end
475
+ end
476
+ @constraint.constant.should == 10
477
+ @constraint.relationship.should == :equal
478
+ @constraint.multiplier.should == 1
479
+ @constraint.relative_to.should == :superview
480
+ @constraint.attribute.should == :right
481
+ @constraint.attribute2.should == :right
482
+ end
483
+ it 'should support `min_right 10`' do
484
+ @layout.context(NSView.new) do
485
+ @layout.constraints do
486
+ @constraint = @layout.min_right(10)
487
+ end
488
+ end
489
+ @constraint.constant.should == 10
490
+ @constraint.relationship.should == :gte
491
+ @constraint.multiplier.should == 1
492
+ @constraint.relative_to.should == :superview
493
+ @constraint.attribute.should == :right
494
+ @constraint.attribute2.should == :right
495
+ end
496
+ it 'should support `max_right 10`' do
497
+ @layout.context(NSView.new) do
498
+ @layout.constraints do
499
+ @constraint = @layout.max_right(10)
500
+ end
501
+ end
502
+ @constraint.constant.should == 10
503
+ @constraint.relationship.should == :lte
504
+ @constraint.multiplier.should == 1
505
+ @constraint.relative_to.should == :superview
506
+ @constraint.attribute.should == :right
507
+ @constraint.attribute2.should == :right
508
+ end
509
+ it 'should support `right.equals(:another_view[, :right])`' do
510
+ @layout.context(NSView.new) do
511
+ @layout.constraints do
512
+ @constraint = @layout.right.equals(:another_view)
513
+ end
514
+ end
515
+ @constraint.constant.should == 0
516
+ @constraint.relationship.should == :equal
517
+ @constraint.multiplier.should == 1
518
+ @constraint.relative_to.should == :another_view
519
+ @constraint.attribute.should == :right
520
+ @constraint.attribute2.should == :right
521
+ end
522
+ it 'should support `min_right.equals(:another_view[, :right])`' do
523
+ @layout.context(NSView.new) do
524
+ @layout.constraints do
525
+ @constraint = @layout.min_right.equals(:another_view)
526
+ end
527
+ end
528
+ @constraint.constant.should == 0
529
+ @constraint.relationship.should == :gte
530
+ @constraint.multiplier.should == 1
531
+ @constraint.relative_to.should == :another_view
532
+ @constraint.attribute.should == :right
533
+ @constraint.attribute2.should == :right
534
+ end
535
+ it 'should support `max_right.equals(:another_view[, :right])`' do
536
+ @layout.context(NSView.new) do
537
+ @layout.constraints do
538
+ @constraint = @layout.max_right.equals(:another_view)
539
+ end
540
+ end
541
+ @constraint.constant.should == 0
542
+ @constraint.relationship.should == :lte
543
+ @constraint.multiplier.should == 1
544
+ @constraint.relative_to.should == :another_view
545
+ @constraint.attribute.should == :right
546
+ @constraint.attribute2.should == :right
547
+ end
548
+ it 'should support `right.equals(:another_view, :left)`' do
549
+ @layout.context(NSView.new) do
550
+ @layout.constraints do
551
+ @constraint = @layout.right.equals(:another_view, :left)
552
+ end
553
+ end
554
+ @constraint.constant.should == 0
555
+ @constraint.relationship.should == :equal
556
+ @constraint.multiplier.should == 1
557
+ @constraint.relative_to.should == :another_view
558
+ @constraint.attribute.should == :right
559
+ @constraint.attribute2.should == :left
560
+ end
561
+ it 'should support `min_right.equals(:another_view, :left)`' do
562
+ @layout.context(NSView.new) do
563
+ @layout.constraints do
564
+ @constraint = @layout.min_right.equals(:another_view, :left)
565
+ end
566
+ end
567
+ @constraint.constant.should == 0
568
+ @constraint.relationship.should == :gte
569
+ @constraint.multiplier.should == 1
570
+ @constraint.relative_to.should == :another_view
571
+ @constraint.attribute.should == :right
572
+ @constraint.attribute2.should == :left
573
+ end
574
+ it 'should support `max_right.equals(:another_view, :left)`' do
575
+ @layout.context(NSView.new) do
576
+ @layout.constraints do
577
+ @constraint = @layout.max_right.equals(:another_view, :left)
578
+ end
579
+ end
580
+ @constraint.constant.should == 0
581
+ @constraint.relationship.should == :lte
582
+ @constraint.multiplier.should == 1
583
+ @constraint.relative_to.should == :another_view
584
+ @constraint.attribute.should == :right
585
+ @constraint.attribute2.should == :left
586
+ end
587
+ it 'should support `right.equals(:another_view, :left).plus(10)`' do
588
+ @layout.context(NSView.new) do
589
+ @layout.constraints do
590
+ @constraint = @layout.right.equals(:another_view, :left).plus(10)
591
+ end
592
+ end
593
+ @constraint.constant.should == 10
594
+ @constraint.relationship.should == :equal
595
+ @constraint.multiplier.should == 1
596
+ @constraint.relative_to.should == :another_view
597
+ @constraint.attribute.should == :right
598
+ @constraint.attribute2.should == :left
599
+ end
600
+ it 'should support `min_right.equals(:another_view, :left).plus(10)`' do
601
+ @layout.context(NSView.new) do
602
+ @layout.constraints do
603
+ @constraint = @layout.min_right.equals(:another_view, :left).plus(10)
604
+ end
605
+ end
606
+ @constraint.constant.should == 10
607
+ @constraint.relationship.should == :gte
608
+ @constraint.multiplier.should == 1
609
+ @constraint.relative_to.should == :another_view
610
+ @constraint.attribute.should == :right
611
+ @constraint.attribute2.should == :left
612
+ end
613
+ it 'should support `max_right.equals(:another_view, :left).plus(10)`' do
614
+ @layout.context(NSView.new) do
615
+ @layout.constraints do
616
+ @constraint = @layout.max_right.equals(:another_view, :left).plus(10)
617
+ end
618
+ end
619
+ @constraint.constant.should == 10
620
+ @constraint.relationship.should == :lte
621
+ @constraint.multiplier.should == 1
622
+ @constraint.relative_to.should == :another_view
623
+ @constraint.attribute.should == :right
624
+ @constraint.attribute2.should == :left
625
+ end
626
+ it 'should support `right.equals(:another_view).times(2).plus(10)`' do
627
+ @layout.context(NSView.new) do
628
+ @layout.constraints do
629
+ @constraint = @layout.right.equals(:another_view).times(2).plus(10)
630
+ end
631
+ end
632
+ @constraint.constant.should == 10
633
+ @constraint.relationship.should == :equal
634
+ @constraint.multiplier.should == 2
635
+ @constraint.relative_to.should == :another_view
636
+ @constraint.attribute.should == :right
637
+ @constraint.attribute2.should == :right
638
+ end
639
+ it 'should support `min_right.equals(:another_view).times(2).plus(10)`' do
640
+ @layout.context(NSView.new) do
641
+ @layout.constraints do
642
+ @constraint = @layout.min_right.equals(:another_view).times(2).plus(10)
643
+ end
644
+ end
645
+ @constraint.constant.should == 10
646
+ @constraint.relationship.should == :gte
647
+ @constraint.multiplier.should == 2
648
+ @constraint.relative_to.should == :another_view
649
+ @constraint.attribute.should == :right
650
+ @constraint.attribute2.should == :right
651
+ end
652
+ it 'should support `max_right.equals(:another_view).times(2).plus(10)`' do
653
+ @layout.context(NSView.new) do
654
+ @layout.constraints do
655
+ @constraint = @layout.max_right.equals(:another_view).times(2).plus(10)
656
+ end
657
+ end
658
+ @constraint.constant.should == 10
659
+ @constraint.relationship.should == :lte
660
+ @constraint.multiplier.should == 2
661
+ @constraint.relative_to.should == :another_view
662
+ @constraint.attribute.should == :right
663
+ @constraint.attribute2.should == :right
664
+ end
665
+ end
666
+
667
+ describe '`y/top` support' do
668
+ it 'should support `y 10`' do
669
+ @layout.context(NSView.new) do
670
+ @layout.constraints do
671
+ @constraint = @layout.y(10)
672
+ end
673
+ end
674
+ @constraint.constant.should == 10
675
+ @constraint.relationship.should == :equal
676
+ @constraint.multiplier.should == 1
677
+ @constraint.relative_to.should == :superview
678
+ @constraint.attribute.should == :top
679
+ @constraint.attribute2.should == :top
680
+ end
681
+ it 'should support `min_y 10`' do
682
+ @layout.context(NSView.new) do
683
+ @layout.constraints do
684
+ @constraint = @layout.min_y(10)
685
+ end
686
+ end
687
+ @constraint.constant.should == 10
688
+ @constraint.relationship.should == :gte
689
+ @constraint.multiplier.should == 1
690
+ @constraint.relative_to.should == :superview
691
+ @constraint.attribute.should == :top
692
+ @constraint.attribute2.should == :top
693
+ end
694
+ it 'should support `max_y 10`' do
695
+ @layout.context(NSView.new) do
696
+ @layout.constraints do
697
+ @constraint = @layout.max_y(10)
698
+ end
699
+ end
700
+ @constraint.constant.should == 10
701
+ @constraint.relationship.should == :lte
702
+ @constraint.multiplier.should == 1
703
+ @constraint.relative_to.should == :superview
704
+ @constraint.attribute.should == :top
705
+ @constraint.attribute2.should == :top
706
+ end
707
+ it 'should support `y.equals(:another_view[, :top])`' do
708
+ @layout.context(NSView.new) do
709
+ @layout.constraints do
710
+ @constraint = @layout.y.equals(:another_view)
711
+ end
712
+ end
713
+ @constraint.constant.should == 0
714
+ @constraint.relationship.should == :equal
715
+ @constraint.multiplier.should == 1
716
+ @constraint.relative_to.should == :another_view
717
+ @constraint.attribute.should == :top
718
+ @constraint.attribute2.should == :top
719
+ end
720
+ it 'should support `min_y.equals(:another_view[, :top])`' do
721
+ @layout.context(NSView.new) do
722
+ @layout.constraints do
723
+ @constraint = @layout.min_y.equals(:another_view)
724
+ end
725
+ end
726
+ @constraint.constant.should == 0
727
+ @constraint.relationship.should == :gte
728
+ @constraint.multiplier.should == 1
729
+ @constraint.relative_to.should == :another_view
730
+ @constraint.attribute.should == :top
731
+ @constraint.attribute2.should == :top
732
+ end
733
+ it 'should support `max_y.equals(:another_view[, :top])`' do
734
+ @layout.context(NSView.new) do
735
+ @layout.constraints do
736
+ @constraint = @layout.max_y.equals(:another_view)
737
+ end
738
+ end
739
+ @constraint.constant.should == 0
740
+ @constraint.relationship.should == :lte
741
+ @constraint.multiplier.should == 1
742
+ @constraint.relative_to.should == :another_view
743
+ @constraint.attribute.should == :top
744
+ @constraint.attribute2.should == :top
745
+ end
746
+ it 'should support `y.equals(:another_view, :bottom)`' do
747
+ @layout.context(NSView.new) do
748
+ @layout.constraints do
749
+ @constraint = @layout.y.equals(:another_view, :bottom)
750
+ end
751
+ end
752
+ @constraint.constant.should == 0
753
+ @constraint.relationship.should == :equal
754
+ @constraint.multiplier.should == 1
755
+ @constraint.relative_to.should == :another_view
756
+ @constraint.attribute.should == :top
757
+ @constraint.attribute2.should == :bottom
758
+ end
759
+ it 'should support `min_y.equals(:another_view, :bottom)`' do
760
+ @layout.context(NSView.new) do
761
+ @layout.constraints do
762
+ @constraint = @layout.min_y.equals(:another_view, :bottom)
763
+ end
764
+ end
765
+ @constraint.constant.should == 0
766
+ @constraint.relationship.should == :gte
767
+ @constraint.multiplier.should == 1
768
+ @constraint.relative_to.should == :another_view
769
+ @constraint.attribute.should == :top
770
+ @constraint.attribute2.should == :bottom
771
+ end
772
+ it 'should support `max_y.equals(:another_view, :bottom)`' do
773
+ @layout.context(NSView.new) do
774
+ @layout.constraints do
775
+ @constraint = @layout.max_y.equals(:another_view, :bottom)
776
+ end
777
+ end
778
+ @constraint.constant.should == 0
779
+ @constraint.relationship.should == :lte
780
+ @constraint.multiplier.should == 1
781
+ @constraint.relative_to.should == :another_view
782
+ @constraint.attribute.should == :top
783
+ @constraint.attribute2.should == :bottom
784
+ end
785
+ it 'should support `y.equals(:another_view, :bottom).plus(10)`' do
786
+ @layout.context(NSView.new) do
787
+ @layout.constraints do
788
+ @constraint = @layout.y.equals(:another_view, :bottom).plus(10)
789
+ end
790
+ end
791
+ @constraint.constant.should == 10
792
+ @constraint.relationship.should == :equal
793
+ @constraint.multiplier.should == 1
794
+ @constraint.relative_to.should == :another_view
795
+ @constraint.attribute.should == :top
796
+ @constraint.attribute2.should == :bottom
797
+ end
798
+ it 'should support `min_y.equals(:another_view, :bottom).plus(10)`' do
799
+ @layout.context(NSView.new) do
800
+ @layout.constraints do
801
+ @constraint = @layout.min_y.equals(:another_view, :bottom).plus(10)
802
+ end
803
+ end
804
+ @constraint.constant.should == 10
805
+ @constraint.relationship.should == :gte
806
+ @constraint.multiplier.should == 1
807
+ @constraint.relative_to.should == :another_view
808
+ @constraint.attribute.should == :top
809
+ @constraint.attribute2.should == :bottom
810
+ end
811
+ it 'should support `max_y.equals(:another_view, :bottom).plus(10)`' do
812
+ @layout.context(NSView.new) do
813
+ @layout.constraints do
814
+ @constraint = @layout.max_y.equals(:another_view, :bottom).plus(10)
815
+ end
816
+ end
817
+ @constraint.constant.should == 10
818
+ @constraint.relationship.should == :lte
819
+ @constraint.multiplier.should == 1
820
+ @constraint.relative_to.should == :another_view
821
+ @constraint.attribute.should == :top
822
+ @constraint.attribute2.should == :bottom
823
+ end
824
+ it 'should support `y.equals(:another_view).times(2).plus(10)`' do
825
+ @layout.context(NSView.new) do
826
+ @layout.constraints do
827
+ @constraint = @layout.y.equals(:another_view).times(2).plus(10)
828
+ end
829
+ end
830
+ @constraint.constant.should == 10
831
+ @constraint.relationship.should == :equal
832
+ @constraint.multiplier.should == 2
833
+ @constraint.relative_to.should == :another_view
834
+ @constraint.attribute.should == :top
835
+ @constraint.attribute2.should == :top
836
+ end
837
+ it 'should support `min_y.equals(:another_view).times(2).plus(10)`' do
838
+ @layout.context(NSView.new) do
839
+ @layout.constraints do
840
+ @constraint = @layout.min_y.equals(:another_view).times(2).plus(10)
841
+ end
842
+ end
843
+ @constraint.constant.should == 10
844
+ @constraint.relationship.should == :gte
845
+ @constraint.multiplier.should == 2
846
+ @constraint.relative_to.should == :another_view
847
+ @constraint.attribute.should == :top
848
+ @constraint.attribute2.should == :top
849
+ end
850
+ it 'should support `max_y.equals(:another_view).times(2).plus(10)`' do
851
+ @layout.context(NSView.new) do
852
+ @layout.constraints do
853
+ @constraint = @layout.max_y.equals(:another_view).times(2).plus(10)
854
+ end
855
+ end
856
+ @constraint.constant.should == 10
857
+ @constraint.relationship.should == :lte
858
+ @constraint.multiplier.should == 2
859
+ @constraint.relative_to.should == :another_view
860
+ @constraint.attribute.should == :top
861
+ @constraint.attribute2.should == :top
862
+ end
863
+ it 'should support `top.equals(:another_view).times(2).plus(10)`' do
864
+ @layout.context(NSView.new) do
865
+ @layout.constraints do
866
+ @constraint = @layout.top.equals(:another_view).times(2).plus(10)
867
+ end
868
+ end
869
+ @constraint.constant.should == 10
870
+ @constraint.relationship.should == :equal
871
+ @constraint.multiplier.should == 2
872
+ @constraint.relative_to.should == :another_view
873
+ @constraint.attribute.should == :top
874
+ @constraint.attribute2.should == :top
875
+ end
876
+ it 'should support `min_top.equals(:another_view).times(2).plus(10)`' do
877
+ @layout.context(NSView.new) do
878
+ @layout.constraints do
879
+ @constraint = @layout.min_top.equals(:another_view).times(2).plus(10)
880
+ end
881
+ end
882
+ @constraint.constant.should == 10
883
+ @constraint.relationship.should == :gte
884
+ @constraint.multiplier.should == 2
885
+ @constraint.relative_to.should == :another_view
886
+ @constraint.attribute.should == :top
887
+ @constraint.attribute2.should == :top
888
+ end
889
+ it 'should support `max_top.equals(:another_view).times(2).plus(10)`' do
890
+ @layout.context(NSView.new) do
891
+ @layout.constraints do
892
+ @constraint = @layout.max_top.equals(:another_view).times(2).plus(10)
893
+ end
894
+ end
895
+ @constraint.constant.should == 10
896
+ @constraint.relationship.should == :lte
897
+ @constraint.multiplier.should == 2
898
+ @constraint.relative_to.should == :another_view
899
+ @constraint.attribute.should == :top
900
+ @constraint.attribute2.should == :top
901
+ end
902
+ end
903
+
904
+ describe '`center_y` support' do
905
+ it 'should support `center_y 10`' do
906
+ @layout.context(NSView.new) do
907
+ @layout.constraints do
908
+ @constraint = @layout.center_y(10)
909
+ end
910
+ end
911
+ @constraint.constant.should == 10
912
+ @constraint.relationship.should == :equal
913
+ @constraint.multiplier.should == 1
914
+ @constraint.relative_to.should == :superview
915
+ @constraint.attribute.should == :center_y
916
+ @constraint.attribute2.should == :center_y
917
+ end
918
+ it 'should support `min_center_y 10`' do
919
+ @layout.context(NSView.new) do
920
+ @layout.constraints do
921
+ @constraint = @layout.min_center_y(10)
922
+ end
923
+ end
924
+ @constraint.constant.should == 10
925
+ @constraint.relationship.should == :gte
926
+ @constraint.multiplier.should == 1
927
+ @constraint.relative_to.should == :superview
928
+ @constraint.attribute.should == :center_y
929
+ @constraint.attribute2.should == :center_y
930
+ end
931
+ it 'should support `max_center_y 10`' do
932
+ @layout.context(NSView.new) do
933
+ @layout.constraints do
934
+ @constraint = @layout.max_center_y(10)
935
+ end
936
+ end
937
+ @constraint.constant.should == 10
938
+ @constraint.relationship.should == :lte
939
+ @constraint.multiplier.should == 1
940
+ @constraint.relative_to.should == :superview
941
+ @constraint.attribute.should == :center_y
942
+ @constraint.attribute2.should == :center_y
943
+ end
944
+ it 'should support `center_y.equals(:another_view[, :center_y])`' do
945
+ @layout.context(NSView.new) do
946
+ @layout.constraints do
947
+ @constraint = @layout.center_y.equals(:another_view)
948
+ end
949
+ end
950
+ @constraint.constant.should == 0
951
+ @constraint.relationship.should == :equal
952
+ @constraint.multiplier.should == 1
953
+ @constraint.relative_to.should == :another_view
954
+ @constraint.attribute.should == :center_y
955
+ @constraint.attribute2.should == :center_y
956
+ end
957
+ it 'should support `min_center_y.equals(:another_view[, :center_y])`' do
958
+ @layout.context(NSView.new) do
959
+ @layout.constraints do
960
+ @constraint = @layout.min_center_y.equals(:another_view)
961
+ end
962
+ end
963
+ @constraint.constant.should == 0
964
+ @constraint.relationship.should == :gte
965
+ @constraint.multiplier.should == 1
966
+ @constraint.relative_to.should == :another_view
967
+ @constraint.attribute.should == :center_y
968
+ @constraint.attribute2.should == :center_y
969
+ end
970
+ it 'should support `max_center_y.equals(:another_view[, :center_y])`' do
971
+ @layout.context(NSView.new) do
972
+ @layout.constraints do
973
+ @constraint = @layout.max_center_y.equals(:another_view)
974
+ end
975
+ end
976
+ @constraint.constant.should == 0
977
+ @constraint.relationship.should == :lte
978
+ @constraint.multiplier.should == 1
979
+ @constraint.relative_to.should == :another_view
980
+ @constraint.attribute.should == :center_y
981
+ @constraint.attribute2.should == :center_y
982
+ end
983
+ it 'should support `center_y.equals(:another_view, :top)`' do
984
+ @layout.context(NSView.new) do
985
+ @layout.constraints do
986
+ @constraint = @layout.center_y.equals(:another_view, :top)
987
+ end
988
+ end
989
+ @constraint.constant.should == 0
990
+ @constraint.relationship.should == :equal
991
+ @constraint.multiplier.should == 1
992
+ @constraint.relative_to.should == :another_view
993
+ @constraint.attribute.should == :center_y
994
+ @constraint.attribute2.should == :top
995
+ end
996
+ it 'should support `min_center_y.equals(:another_view, :top)`' do
997
+ @layout.context(NSView.new) do
998
+ @layout.constraints do
999
+ @constraint = @layout.min_center_y.equals(:another_view, :top)
1000
+ end
1001
+ end
1002
+ @constraint.constant.should == 0
1003
+ @constraint.relationship.should == :gte
1004
+ @constraint.multiplier.should == 1
1005
+ @constraint.relative_to.should == :another_view
1006
+ @constraint.attribute.should == :center_y
1007
+ @constraint.attribute2.should == :top
1008
+ end
1009
+ it 'should support `max_center_y.equals(:another_view, :top)`' do
1010
+ @layout.context(NSView.new) do
1011
+ @layout.constraints do
1012
+ @constraint = @layout.max_center_y.equals(:another_view, :top)
1013
+ end
1014
+ end
1015
+ @constraint.constant.should == 0
1016
+ @constraint.relationship.should == :lte
1017
+ @constraint.multiplier.should == 1
1018
+ @constraint.relative_to.should == :another_view
1019
+ @constraint.attribute.should == :center_y
1020
+ @constraint.attribute2.should == :top
1021
+ end
1022
+ it 'should support `center_y.equals(:another_view, :top).plus(10)`' do
1023
+ @layout.context(NSView.new) do
1024
+ @layout.constraints do
1025
+ @constraint = @layout.center_y.equals(:another_view, :top).plus(10)
1026
+ end
1027
+ end
1028
+ @constraint.constant.should == 10
1029
+ @constraint.relationship.should == :equal
1030
+ @constraint.multiplier.should == 1
1031
+ @constraint.relative_to.should == :another_view
1032
+ @constraint.attribute.should == :center_y
1033
+ @constraint.attribute2.should == :top
1034
+ end
1035
+ it 'should support `min_center_y.equals(:another_view, :top).plus(10)`' do
1036
+ @layout.context(NSView.new) do
1037
+ @layout.constraints do
1038
+ @constraint = @layout.min_center_y.equals(:another_view, :top).plus(10)
1039
+ end
1040
+ end
1041
+ @constraint.constant.should == 10
1042
+ @constraint.relationship.should == :gte
1043
+ @constraint.multiplier.should == 1
1044
+ @constraint.relative_to.should == :another_view
1045
+ @constraint.attribute.should == :center_y
1046
+ @constraint.attribute2.should == :top
1047
+ end
1048
+ it 'should support `max_center_y.equals(:another_view, :top).plus(10)`' do
1049
+ @layout.context(NSView.new) do
1050
+ @layout.constraints do
1051
+ @constraint = @layout.max_center_y.equals(:another_view, :top).plus(10)
1052
+ end
1053
+ end
1054
+ @constraint.constant.should == 10
1055
+ @constraint.relationship.should == :lte
1056
+ @constraint.multiplier.should == 1
1057
+ @constraint.relative_to.should == :another_view
1058
+ @constraint.attribute.should == :center_y
1059
+ @constraint.attribute2.should == :top
1060
+ end
1061
+ it 'should support `center_y.equals(:another_view).times(2).plus(10)`' do
1062
+ @layout.context(NSView.new) do
1063
+ @layout.constraints do
1064
+ @constraint = @layout.center_y.equals(:another_view).times(2).plus(10)
1065
+ end
1066
+ end
1067
+ @constraint.constant.should == 10
1068
+ @constraint.relationship.should == :equal
1069
+ @constraint.multiplier.should == 2
1070
+ @constraint.relative_to.should == :another_view
1071
+ @constraint.attribute.should == :center_y
1072
+ @constraint.attribute2.should == :center_y
1073
+ end
1074
+ it 'should support `min_center_y.equals(:another_view).times(2).plus(10)`' do
1075
+ @layout.context(NSView.new) do
1076
+ @layout.constraints do
1077
+ @constraint = @layout.min_center_y.equals(:another_view).times(2).plus(10)
1078
+ end
1079
+ end
1080
+ @constraint.constant.should == 10
1081
+ @constraint.relationship.should == :gte
1082
+ @constraint.multiplier.should == 2
1083
+ @constraint.relative_to.should == :another_view
1084
+ @constraint.attribute.should == :center_y
1085
+ @constraint.attribute2.should == :center_y
1086
+ end
1087
+ it 'should support `max_center_y.equals(:another_view).times(2).plus(10)`' do
1088
+ @layout.context(NSView.new) do
1089
+ @layout.constraints do
1090
+ @constraint = @layout.max_center_y.equals(:another_view).times(2).plus(10)
1091
+ end
1092
+ end
1093
+ @constraint.constant.should == 10
1094
+ @constraint.relationship.should == :lte
1095
+ @constraint.multiplier.should == 2
1096
+ @constraint.relative_to.should == :another_view
1097
+ @constraint.attribute.should == :center_y
1098
+ @constraint.attribute2.should == :center_y
1099
+ end
1100
+ end
1101
+
1102
+ describe '`bottom` support' do
1103
+ it 'should support `bottom 10`' do
1104
+ @layout.context(NSView.new) do
1105
+ @layout.constraints do
1106
+ @constraint = @layout.bottom(10)
1107
+ end
1108
+ end
1109
+ @constraint.constant.should == 10
1110
+ @constraint.relationship.should == :equal
1111
+ @constraint.multiplier.should == 1
1112
+ @constraint.relative_to.should == :superview
1113
+ @constraint.attribute.should == :bottom
1114
+ @constraint.attribute2.should == :bottom
1115
+ end
1116
+ it 'should support `min_bottom 10`' do
1117
+ @layout.context(NSView.new) do
1118
+ @layout.constraints do
1119
+ @constraint = @layout.min_bottom(10)
1120
+ end
1121
+ end
1122
+ @constraint.constant.should == 10
1123
+ @constraint.relationship.should == :gte
1124
+ @constraint.multiplier.should == 1
1125
+ @constraint.relative_to.should == :superview
1126
+ @constraint.attribute.should == :bottom
1127
+ @constraint.attribute2.should == :bottom
1128
+ end
1129
+ it 'should support `max_bottom 10`' do
1130
+ @layout.context(NSView.new) do
1131
+ @layout.constraints do
1132
+ @constraint = @layout.max_bottom(10)
1133
+ end
1134
+ end
1135
+ @constraint.constant.should == 10
1136
+ @constraint.relationship.should == :lte
1137
+ @constraint.multiplier.should == 1
1138
+ @constraint.relative_to.should == :superview
1139
+ @constraint.attribute.should == :bottom
1140
+ @constraint.attribute2.should == :bottom
1141
+ end
1142
+ it 'should support `bottom.equals(:another_view[, :bottom])`' do
1143
+ @layout.context(NSView.new) do
1144
+ @layout.constraints do
1145
+ @constraint = @layout.bottom.equals(:another_view)
1146
+ end
1147
+ end
1148
+ @constraint.constant.should == 0
1149
+ @constraint.relationship.should == :equal
1150
+ @constraint.multiplier.should == 1
1151
+ @constraint.relative_to.should == :another_view
1152
+ @constraint.attribute.should == :bottom
1153
+ @constraint.attribute2.should == :bottom
1154
+ end
1155
+ it 'should support `min_bottom.equals(:another_view[, :bottom])`' do
1156
+ @layout.context(NSView.new) do
1157
+ @layout.constraints do
1158
+ @constraint = @layout.min_bottom.equals(:another_view)
1159
+ end
1160
+ end
1161
+ @constraint.constant.should == 0
1162
+ @constraint.relationship.should == :gte
1163
+ @constraint.multiplier.should == 1
1164
+ @constraint.relative_to.should == :another_view
1165
+ @constraint.attribute.should == :bottom
1166
+ @constraint.attribute2.should == :bottom
1167
+ end
1168
+ it 'should support `max_bottom.equals(:another_view[, :bottom])`' do
1169
+ @layout.context(NSView.new) do
1170
+ @layout.constraints do
1171
+ @constraint = @layout.max_bottom.equals(:another_view)
1172
+ end
1173
+ end
1174
+ @constraint.constant.should == 0
1175
+ @constraint.relationship.should == :lte
1176
+ @constraint.multiplier.should == 1
1177
+ @constraint.relative_to.should == :another_view
1178
+ @constraint.attribute.should == :bottom
1179
+ @constraint.attribute2.should == :bottom
1180
+ end
1181
+ it 'should support `bottom.equals(:another_view, :top)`' do
1182
+ @layout.context(NSView.new) do
1183
+ @layout.constraints do
1184
+ @constraint = @layout.bottom.equals(:another_view, :top)
1185
+ end
1186
+ end
1187
+ @constraint.constant.should == 0
1188
+ @constraint.relationship.should == :equal
1189
+ @constraint.multiplier.should == 1
1190
+ @constraint.relative_to.should == :another_view
1191
+ @constraint.attribute.should == :bottom
1192
+ @constraint.attribute2.should == :top
1193
+ end
1194
+ it 'should support `min_bottom.equals(:another_view, :top)`' do
1195
+ @layout.context(NSView.new) do
1196
+ @layout.constraints do
1197
+ @constraint = @layout.min_bottom.equals(:another_view, :top)
1198
+ end
1199
+ end
1200
+ @constraint.constant.should == 0
1201
+ @constraint.relationship.should == :gte
1202
+ @constraint.multiplier.should == 1
1203
+ @constraint.relative_to.should == :another_view
1204
+ @constraint.attribute.should == :bottom
1205
+ @constraint.attribute2.should == :top
1206
+ end
1207
+ it 'should support `max_bottom.equals(:another_view, :top)`' do
1208
+ @layout.context(NSView.new) do
1209
+ @layout.constraints do
1210
+ @constraint = @layout.max_bottom.equals(:another_view, :top)
1211
+ end
1212
+ end
1213
+ @constraint.constant.should == 0
1214
+ @constraint.relationship.should == :lte
1215
+ @constraint.multiplier.should == 1
1216
+ @constraint.relative_to.should == :another_view
1217
+ @constraint.attribute.should == :bottom
1218
+ @constraint.attribute2.should == :top
1219
+ end
1220
+ it 'should support `bottom.equals(:another_view, :top).plus(10)`' do
1221
+ @layout.context(NSView.new) do
1222
+ @layout.constraints do
1223
+ @constraint = @layout.bottom.equals(:another_view, :top).plus(10)
1224
+ end
1225
+ end
1226
+ @constraint.constant.should == 10
1227
+ @constraint.relationship.should == :equal
1228
+ @constraint.multiplier.should == 1
1229
+ @constraint.relative_to.should == :another_view
1230
+ @constraint.attribute.should == :bottom
1231
+ @constraint.attribute2.should == :top
1232
+ end
1233
+ it 'should support `min_bottom.equals(:another_view, :top).plus(10)`' do
1234
+ @layout.context(NSView.new) do
1235
+ @layout.constraints do
1236
+ @constraint = @layout.min_bottom.equals(:another_view, :top).plus(10)
1237
+ end
1238
+ end
1239
+ @constraint.constant.should == 10
1240
+ @constraint.relationship.should == :gte
1241
+ @constraint.multiplier.should == 1
1242
+ @constraint.relative_to.should == :another_view
1243
+ @constraint.attribute.should == :bottom
1244
+ @constraint.attribute2.should == :top
1245
+ end
1246
+ it 'should support `max_bottom.equals(:another_view, :top).plus(10)`' do
1247
+ @layout.context(NSView.new) do
1248
+ @layout.constraints do
1249
+ @constraint = @layout.max_bottom.equals(:another_view, :top).plus(10)
1250
+ end
1251
+ end
1252
+ @constraint.constant.should == 10
1253
+ @constraint.relationship.should == :lte
1254
+ @constraint.multiplier.should == 1
1255
+ @constraint.relative_to.should == :another_view
1256
+ @constraint.attribute.should == :bottom
1257
+ @constraint.attribute2.should == :top
1258
+ end
1259
+ it 'should support `bottom.equals(:another_view).times(2).plus(10)`' do
1260
+ @layout.context(NSView.new) do
1261
+ @layout.constraints do
1262
+ @constraint = @layout.bottom.equals(:another_view).times(2).plus(10)
1263
+ end
1264
+ end
1265
+ @constraint.constant.should == 10
1266
+ @constraint.relationship.should == :equal
1267
+ @constraint.multiplier.should == 2
1268
+ @constraint.relative_to.should == :another_view
1269
+ @constraint.attribute.should == :bottom
1270
+ @constraint.attribute2.should == :bottom
1271
+ end
1272
+ it 'should support `min_bottom.equals(:another_view).times(2).plus(10)`' do
1273
+ @layout.context(NSView.new) do
1274
+ @layout.constraints do
1275
+ @constraint = @layout.min_bottom.equals(:another_view).times(2).plus(10)
1276
+ end
1277
+ end
1278
+ @constraint.constant.should == 10
1279
+ @constraint.relationship.should == :gte
1280
+ @constraint.multiplier.should == 2
1281
+ @constraint.relative_to.should == :another_view
1282
+ @constraint.attribute.should == :bottom
1283
+ @constraint.attribute2.should == :bottom
1284
+ end
1285
+ it 'should support `max_bottom.equals(:another_view).times(2).plus(10)`' do
1286
+ @layout.context(NSView.new) do
1287
+ @layout.constraints do
1288
+ @constraint = @layout.max_bottom.equals(:another_view).times(2).plus(10)
1289
+ end
1290
+ end
1291
+ @constraint.constant.should == 10
1292
+ @constraint.relationship.should == :lte
1293
+ @constraint.multiplier.should == 2
1294
+ @constraint.relative_to.should == :another_view
1295
+ @constraint.attribute.should == :bottom
1296
+ @constraint.attribute2.should == :bottom
1297
+ end
1298
+ end
1299
+
1300
+ describe '`width` support' do
1301
+ it 'should support `width 10`' do
1302
+ @layout.context(NSView.new) do
1303
+ @layout.constraints do
1304
+ @constraint = @layout.width(10)
1305
+ end
1306
+ end
1307
+ @constraint.constant.should == 10
1308
+ @constraint.relationship.should == :equal
1309
+ @constraint.multiplier.should == 1
1310
+ @constraint.relative_to.should == nil
1311
+ @constraint.attribute.should == :width
1312
+ @constraint.attribute2.should == :width
1313
+ end
1314
+ it 'should support `min_width 10`' do
1315
+ @layout.context(NSView.new) do
1316
+ @layout.constraints do
1317
+ @constraint = @layout.min_width(10)
1318
+ end
1319
+ end
1320
+ @constraint.constant.should == 10
1321
+ @constraint.relationship.should == :gte
1322
+ @constraint.multiplier.should == 1
1323
+ @constraint.relative_to.should == nil
1324
+ @constraint.attribute.should == :width
1325
+ @constraint.attribute2.should == :width
1326
+ end
1327
+ it 'should support `max_width 10`' do
1328
+ @layout.context(NSView.new) do
1329
+ @layout.constraints do
1330
+ @constraint = @layout.max_width(10)
1331
+ end
1332
+ end
1333
+ @constraint.constant.should == 10
1334
+ @constraint.relationship.should == :lte
1335
+ @constraint.multiplier.should == 1
1336
+ @constraint.relative_to.should == nil
1337
+ @constraint.attribute.should == :width
1338
+ @constraint.attribute2.should == :width
1339
+ end
1340
+ it 'should support `width.equals(:another_view[, :width])`' do
1341
+ @layout.context(NSView.new) do
1342
+ @layout.constraints do
1343
+ @constraint = @layout.width.equals(:another_view)
1344
+ end
1345
+ end
1346
+ @constraint.constant.should == 0
1347
+ @constraint.relationship.should == :equal
1348
+ @constraint.multiplier.should == 1
1349
+ @constraint.relative_to.should == :another_view
1350
+ @constraint.attribute.should == :width
1351
+ @constraint.attribute2.should == :width
1352
+ end
1353
+ it 'should support `min_width.equals(:another_view[, :width])`' do
1354
+ @layout.context(NSView.new) do
1355
+ @layout.constraints do
1356
+ @constraint = @layout.min_width.equals(:another_view)
1357
+ end
1358
+ end
1359
+ @constraint.constant.should == 0
1360
+ @constraint.relationship.should == :gte
1361
+ @constraint.multiplier.should == 1
1362
+ @constraint.relative_to.should == :another_view
1363
+ @constraint.attribute.should == :width
1364
+ @constraint.attribute2.should == :width
1365
+ end
1366
+ it 'should support `max_width.equals(:another_view[, :width])`' do
1367
+ @layout.context(NSView.new) do
1368
+ @layout.constraints do
1369
+ @constraint = @layout.max_width.equals(:another_view)
1370
+ end
1371
+ end
1372
+ @constraint.constant.should == 0
1373
+ @constraint.relationship.should == :lte
1374
+ @constraint.multiplier.should == 1
1375
+ @constraint.relative_to.should == :another_view
1376
+ @constraint.attribute.should == :width
1377
+ @constraint.attribute2.should == :width
1378
+ end
1379
+ it 'should support `width.equals(:another_view, :height).plus(10)`' do
1380
+ @layout.context(NSView.new) do
1381
+ @layout.constraints do
1382
+ @constraint = @layout.width.equals(:another_view, :height).plus(10)
1383
+ end
1384
+ end
1385
+ @constraint.constant.should == 10
1386
+ @constraint.relationship.should == :equal
1387
+ @constraint.multiplier.should == 1
1388
+ @constraint.relative_to.should == :another_view
1389
+ @constraint.attribute.should == :width
1390
+ @constraint.attribute2.should == :height
1391
+ end
1392
+ it 'should support `min_width.equals(:another_view, :height).plus(10)`' do
1393
+ @layout.context(NSView.new) do
1394
+ @layout.constraints do
1395
+ @constraint = @layout.min_width.equals(:another_view, :height).plus(10)
1396
+ end
1397
+ end
1398
+ @constraint.constant.should == 10
1399
+ @constraint.relationship.should == :gte
1400
+ @constraint.multiplier.should == 1
1401
+ @constraint.relative_to.should == :another_view
1402
+ @constraint.attribute.should == :width
1403
+ @constraint.attribute2.should == :height
1404
+ end
1405
+ it 'should support `max_width.equals(:another_view, :height).plus(10)`' do
1406
+ @layout.context(NSView.new) do
1407
+ @layout.constraints do
1408
+ @constraint = @layout.max_width.equals(:another_view, :height).plus(10)
1409
+ end
1410
+ end
1411
+ @constraint.constant.should == 10
1412
+ @constraint.relationship.should == :lte
1413
+ @constraint.multiplier.should == 1
1414
+ @constraint.relative_to.should == :another_view
1415
+ @constraint.attribute.should == :width
1416
+ @constraint.attribute2.should == :height
1417
+ end
1418
+ it 'should support `width.equals(:another_view).times(2).plus(10)`' do
1419
+ @layout.context(NSView.new) do
1420
+ @layout.constraints do
1421
+ @constraint = @layout.width.equals(:another_view).times(2).plus(10)
1422
+ end
1423
+ end
1424
+ @constraint.constant.should == 10
1425
+ @constraint.relationship.should == :equal
1426
+ @constraint.multiplier.should == 2
1427
+ @constraint.relative_to.should == :another_view
1428
+ @constraint.attribute.should == :width
1429
+ @constraint.attribute2.should == :width
1430
+ end
1431
+ it 'should support `min_width.equals(:another_view).times(2).plus(10)`' do
1432
+ @layout.context(NSView.new) do
1433
+ @layout.constraints do
1434
+ @constraint = @layout.min_width.equals(:another_view).times(2).plus(10)
1435
+ end
1436
+ end
1437
+ @constraint.constant.should == 10
1438
+ @constraint.relationship.should == :gte
1439
+ @constraint.multiplier.should == 2
1440
+ @constraint.relative_to.should == :another_view
1441
+ @constraint.attribute.should == :width
1442
+ @constraint.attribute2.should == :width
1443
+ end
1444
+ it 'should support `max_width.equals(:another_view).times(2).plus(10)`' do
1445
+ @layout.context(NSView.new) do
1446
+ @layout.constraints do
1447
+ @constraint = @layout.max_width.equals(:another_view).times(2).plus(10)
1448
+ end
1449
+ end
1450
+ @constraint.constant.should == 10
1451
+ @constraint.relationship.should == :lte
1452
+ @constraint.multiplier.should == 2
1453
+ @constraint.relative_to.should == :another_view
1454
+ @constraint.attribute.should == :width
1455
+ @constraint.attribute2.should == :width
1456
+ end
1457
+ end
1458
+
1459
+ describe '`height` support' do
1460
+ it 'should support `height 10`' do
1461
+ @layout.context(NSView.new) do
1462
+ @layout.constraints do
1463
+ @constraint = @layout.height(10)
1464
+ end
1465
+ end
1466
+ @constraint.constant.should == 10
1467
+ @constraint.relationship.should == :equal
1468
+ @constraint.multiplier.should == 1
1469
+ @constraint.relative_to.should == nil
1470
+ @constraint.attribute.should == :height
1471
+ @constraint.attribute2.should == :height
1472
+ end
1473
+ it 'should support `min_height 10`' do
1474
+ @layout.context(NSView.new) do
1475
+ @layout.constraints do
1476
+ @constraint = @layout.min_height(10)
1477
+ end
1478
+ end
1479
+ @constraint.constant.should == 10
1480
+ @constraint.relationship.should == :gte
1481
+ @constraint.multiplier.should == 1
1482
+ @constraint.relative_to.should == nil
1483
+ @constraint.attribute.should == :height
1484
+ @constraint.attribute2.should == :height
1485
+ end
1486
+ it 'should support `max_height 10`' do
1487
+ @layout.context(NSView.new) do
1488
+ @layout.constraints do
1489
+ @constraint = @layout.max_height(10)
1490
+ end
1491
+ end
1492
+ @constraint.constant.should == 10
1493
+ @constraint.relationship.should == :lte
1494
+ @constraint.multiplier.should == 1
1495
+ @constraint.relative_to.should == nil
1496
+ @constraint.attribute.should == :height
1497
+ @constraint.attribute2.should == :height
1498
+ end
1499
+ it 'should support `height.equals(:another_view[, :height])`' do
1500
+ @layout.context(NSView.new) do
1501
+ @layout.constraints do
1502
+ @constraint = @layout.height.equals(:another_view)
1503
+ end
1504
+ end
1505
+ @constraint.constant.should == 0
1506
+ @constraint.relationship.should == :equal
1507
+ @constraint.multiplier.should == 1
1508
+ @constraint.relative_to.should == :another_view
1509
+ @constraint.attribute.should == :height
1510
+ @constraint.attribute2.should == :height
1511
+ end
1512
+ it 'should support `min_height.equals(:another_view[, :height])`' do
1513
+ @layout.context(NSView.new) do
1514
+ @layout.constraints do
1515
+ @constraint = @layout.min_height.equals(:another_view)
1516
+ end
1517
+ end
1518
+ @constraint.constant.should == 0
1519
+ @constraint.relationship.should == :gte
1520
+ @constraint.multiplier.should == 1
1521
+ @constraint.relative_to.should == :another_view
1522
+ @constraint.attribute.should == :height
1523
+ @constraint.attribute2.should == :height
1524
+ end
1525
+ it 'should support `max_height.equals(:another_view[, :height])`' do
1526
+ @layout.context(NSView.new) do
1527
+ @layout.constraints do
1528
+ @constraint = @layout.max_height.equals(:another_view)
1529
+ end
1530
+ end
1531
+ @constraint.constant.should == 0
1532
+ @constraint.relationship.should == :lte
1533
+ @constraint.multiplier.should == 1
1534
+ @constraint.relative_to.should == :another_view
1535
+ @constraint.attribute.should == :height
1536
+ @constraint.attribute2.should == :height
1537
+ end
1538
+ it 'should support `height.equals(:another_view).plus(10)`' do
1539
+ @layout.context(NSView.new) do
1540
+ @layout.constraints do
1541
+ @constraint = @layout.height.equals(:another_view).plus(10)
1542
+ end
1543
+ end
1544
+ @constraint.constant.should == 10
1545
+ @constraint.relationship.should == :equal
1546
+ @constraint.multiplier.should == 1
1547
+ @constraint.relative_to.should == :another_view
1548
+ @constraint.attribute.should == :height
1549
+ @constraint.attribute2.should == :height
1550
+ end
1551
+ it 'should support `min_height.equals(:another_view).plus(10)`' do
1552
+ @layout.context(NSView.new) do
1553
+ @layout.constraints do
1554
+ @constraint = @layout.min_height.equals(:another_view).plus(10)
1555
+ end
1556
+ end
1557
+ @constraint.constant.should == 10
1558
+ @constraint.relationship.should == :gte
1559
+ @constraint.multiplier.should == 1
1560
+ @constraint.relative_to.should == :another_view
1561
+ @constraint.attribute.should == :height
1562
+ @constraint.attribute2.should == :height
1563
+ end
1564
+ it 'should support `max_height.equals(:another_view).plus(10)`' do
1565
+ @layout.context(NSView.new) do
1566
+ @layout.constraints do
1567
+ @constraint = @layout.max_height.equals(:another_view).plus(10)
1568
+ end
1569
+ end
1570
+ @constraint.constant.should == 10
1571
+ @constraint.relationship.should == :lte
1572
+ @constraint.multiplier.should == 1
1573
+ @constraint.relative_to.should == :another_view
1574
+ @constraint.attribute.should == :height
1575
+ @constraint.attribute2.should == :height
1576
+ end
1577
+ it 'should support `height.equals(:another_view).times(2).plus(10)`' do
1578
+ @layout.context(NSView.new) do
1579
+ @layout.constraints do
1580
+ @constraint = @layout.height.equals(:another_view).times(2).plus(10)
1581
+ end
1582
+ end
1583
+ @constraint.constant.should == 10
1584
+ @constraint.relationship.should == :equal
1585
+ @constraint.multiplier.should == 2
1586
+ @constraint.relative_to.should == :another_view
1587
+ @constraint.attribute.should == :height
1588
+ @constraint.attribute2.should == :height
1589
+ end
1590
+ it 'should support `min_height.equals(:another_view).times(2).plus(10)`' do
1591
+ @layout.context(NSView.new) do
1592
+ @layout.constraints do
1593
+ @constraint = @layout.min_height.equals(:another_view).times(2).plus(10)
1594
+ end
1595
+ end
1596
+ @constraint.constant.should == 10
1597
+ @constraint.relationship.should == :gte
1598
+ @constraint.multiplier.should == 2
1599
+ @constraint.relative_to.should == :another_view
1600
+ @constraint.attribute.should == :height
1601
+ @constraint.attribute2.should == :height
1602
+ end
1603
+ it 'should support `max_height.equals(:another_view).times(2).plus(10)`' do
1604
+ @layout.context(NSView.new) do
1605
+ @layout.constraints do
1606
+ @constraint = @layout.max_height.equals(:another_view).times(2).plus(10)
1607
+ end
1608
+ end
1609
+ @constraint.constant.should == 10
1610
+ @constraint.relationship.should == :lte
1611
+ @constraint.multiplier.should == 2
1612
+ @constraint.relative_to.should == :another_view
1613
+ @constraint.attribute.should == :height
1614
+ @constraint.attribute2.should == :height
1615
+ end
1616
+ end
1617
+
1618
+ describe '`leading` support' do
1619
+ it 'should support `leading 10`' do
1620
+ @layout.context(NSView.new) do
1621
+ @layout.constraints do
1622
+ @constraint = @layout.leading(10)
1623
+ end
1624
+ end
1625
+ @constraint.constant.should == 10
1626
+ @constraint.relationship.should == :equal
1627
+ @constraint.multiplier.should == 1
1628
+ @constraint.relative_to.should == :superview
1629
+ @constraint.attribute.should == :leading
1630
+ @constraint.attribute2.should == :leading
1631
+ end
1632
+ it 'should support `min_leading 10`' do
1633
+ @layout.context(NSView.new) do
1634
+ @layout.constraints do
1635
+ @constraint = @layout.min_leading(10)
1636
+ end
1637
+ end
1638
+ @constraint.constant.should == 10
1639
+ @constraint.relationship.should == :gte
1640
+ @constraint.multiplier.should == 1
1641
+ @constraint.relative_to.should == :superview
1642
+ @constraint.attribute.should == :leading
1643
+ @constraint.attribute2.should == :leading
1644
+ end
1645
+ it 'should support `max_leading 10`' do
1646
+ @layout.context(NSView.new) do
1647
+ @layout.constraints do
1648
+ @constraint = @layout.max_leading(10)
1649
+ end
1650
+ end
1651
+ @constraint.constant.should == 10
1652
+ @constraint.relationship.should == :lte
1653
+ @constraint.multiplier.should == 1
1654
+ @constraint.relative_to.should == :superview
1655
+ @constraint.attribute.should == :leading
1656
+ @constraint.attribute2.should == :leading
1657
+ end
1658
+ it 'should support `leading.equals(:another_view[, :leading])`' do
1659
+ @layout.context(NSView.new) do
1660
+ @layout.constraints do
1661
+ @constraint = @layout.leading.equals(:another_view)
1662
+ end
1663
+ end
1664
+ @constraint.constant.should == 0
1665
+ @constraint.relationship.should == :equal
1666
+ @constraint.multiplier.should == 1
1667
+ @constraint.relative_to.should == :another_view
1668
+ @constraint.attribute.should == :leading
1669
+ @constraint.attribute2.should == :leading
1670
+ end
1671
+ it 'should support `min_leading.equals(:another_view[, :leading])`' do
1672
+ @layout.context(NSView.new) do
1673
+ @layout.constraints do
1674
+ @constraint = @layout.min_leading.equals(:another_view)
1675
+ end
1676
+ end
1677
+ @constraint.constant.should == 0
1678
+ @constraint.relationship.should == :gte
1679
+ @constraint.multiplier.should == 1
1680
+ @constraint.relative_to.should == :another_view
1681
+ @constraint.attribute.should == :leading
1682
+ @constraint.attribute2.should == :leading
1683
+ end
1684
+ it 'should support `max_leading.equals(:another_view[, :leading])`' do
1685
+ @layout.context(NSView.new) do
1686
+ @layout.constraints do
1687
+ @constraint = @layout.max_leading.equals(:another_view)
1688
+ end
1689
+ end
1690
+ @constraint.constant.should == 0
1691
+ @constraint.relationship.should == :lte
1692
+ @constraint.multiplier.should == 1
1693
+ @constraint.relative_to.should == :another_view
1694
+ @constraint.attribute.should == :leading
1695
+ @constraint.attribute2.should == :leading
1696
+ end
1697
+ it 'should support `leading.equals(:another_view).plus(10)`' do
1698
+ @layout.context(NSView.new) do
1699
+ @layout.constraints do
1700
+ @constraint = @layout.leading.equals(:another_view).plus(10)
1701
+ end
1702
+ end
1703
+ @constraint.constant.should == 10
1704
+ @constraint.relationship.should == :equal
1705
+ @constraint.multiplier.should == 1
1706
+ @constraint.relative_to.should == :another_view
1707
+ @constraint.attribute.should == :leading
1708
+ @constraint.attribute2.should == :leading
1709
+ end
1710
+ it 'should support `min_leading.equals(:another_view).plus(10)`' do
1711
+ @layout.context(NSView.new) do
1712
+ @layout.constraints do
1713
+ @constraint = @layout.min_leading.equals(:another_view).plus(10)
1714
+ end
1715
+ end
1716
+ @constraint.constant.should == 10
1717
+ @constraint.relationship.should == :gte
1718
+ @constraint.multiplier.should == 1
1719
+ @constraint.relative_to.should == :another_view
1720
+ @constraint.attribute.should == :leading
1721
+ @constraint.attribute2.should == :leading
1722
+ end
1723
+ it 'should support `max_leading.equals(:another_view).plus(10)`' do
1724
+ @layout.context(NSView.new) do
1725
+ @layout.constraints do
1726
+ @constraint = @layout.max_leading.equals(:another_view).plus(10)
1727
+ end
1728
+ end
1729
+ @constraint.constant.should == 10
1730
+ @constraint.relationship.should == :lte
1731
+ @constraint.multiplier.should == 1
1732
+ @constraint.relative_to.should == :another_view
1733
+ @constraint.attribute.should == :leading
1734
+ @constraint.attribute2.should == :leading
1735
+ end
1736
+ it 'should support `leading.equals(:another_view).times(2).plus(10)`' do
1737
+ @layout.context(NSView.new) do
1738
+ @layout.constraints do
1739
+ @constraint = @layout.leading.equals(:another_view).times(2).plus(10)
1740
+ end
1741
+ end
1742
+ @constraint.constant.should == 10
1743
+ @constraint.relationship.should == :equal
1744
+ @constraint.multiplier.should == 2
1745
+ @constraint.relative_to.should == :another_view
1746
+ @constraint.attribute.should == :leading
1747
+ @constraint.attribute2.should == :leading
1748
+ end
1749
+ it 'should support `min_leading.equals(:another_view).times(2).plus(10)`' do
1750
+ @layout.context(NSView.new) do
1751
+ @layout.constraints do
1752
+ @constraint = @layout.min_leading.equals(:another_view).times(2).plus(10)
1753
+ end
1754
+ end
1755
+ @constraint.constant.should == 10
1756
+ @constraint.relationship.should == :gte
1757
+ @constraint.multiplier.should == 2
1758
+ @constraint.relative_to.should == :another_view
1759
+ @constraint.attribute.should == :leading
1760
+ @constraint.attribute2.should == :leading
1761
+ end
1762
+ it 'should support `max_leading.equals(:another_view).times(2).plus(10)`' do
1763
+ @layout.context(NSView.new) do
1764
+ @layout.constraints do
1765
+ @constraint = @layout.max_leading.equals(:another_view).times(2).plus(10)
1766
+ end
1767
+ end
1768
+ @constraint.constant.should == 10
1769
+ @constraint.relationship.should == :lte
1770
+ @constraint.multiplier.should == 2
1771
+ @constraint.relative_to.should == :another_view
1772
+ @constraint.attribute.should == :leading
1773
+ @constraint.attribute2.should == :leading
1774
+ end
1775
+ end
1776
+
1777
+ describe '`trailing` support' do
1778
+ it 'should support `trailing 10`' do
1779
+ @layout.context(NSView.new) do
1780
+ @layout.constraints do
1781
+ @constraint = @layout.trailing(10)
1782
+ end
1783
+ end
1784
+ @constraint.constant.should == 10
1785
+ @constraint.relationship.should == :equal
1786
+ @constraint.multiplier.should == 1
1787
+ @constraint.relative_to.should == :superview
1788
+ @constraint.attribute.should == :trailing
1789
+ @constraint.attribute2.should == :trailing
1790
+ end
1791
+ it 'should support `min_trailing 10`' do
1792
+ @layout.context(NSView.new) do
1793
+ @layout.constraints do
1794
+ @constraint = @layout.min_trailing(10)
1795
+ end
1796
+ end
1797
+ @constraint.constant.should == 10
1798
+ @constraint.relationship.should == :gte
1799
+ @constraint.multiplier.should == 1
1800
+ @constraint.relative_to.should == :superview
1801
+ @constraint.attribute.should == :trailing
1802
+ @constraint.attribute2.should == :trailing
1803
+ end
1804
+ it 'should support `max_trailing 10`' do
1805
+ @layout.context(NSView.new) do
1806
+ @layout.constraints do
1807
+ @constraint = @layout.max_trailing(10)
1808
+ end
1809
+ end
1810
+ @constraint.constant.should == 10
1811
+ @constraint.relationship.should == :lte
1812
+ @constraint.multiplier.should == 1
1813
+ @constraint.relative_to.should == :superview
1814
+ @constraint.attribute.should == :trailing
1815
+ @constraint.attribute2.should == :trailing
1816
+ end
1817
+ it 'should support `trailing.equals(:another_view[, :trailing])`' do
1818
+ @layout.context(NSView.new) do
1819
+ @layout.constraints do
1820
+ @constraint = @layout.trailing.equals(:another_view)
1821
+ end
1822
+ end
1823
+ @constraint.constant.should == 0
1824
+ @constraint.relationship.should == :equal
1825
+ @constraint.multiplier.should == 1
1826
+ @constraint.relative_to.should == :another_view
1827
+ @constraint.attribute.should == :trailing
1828
+ @constraint.attribute2.should == :trailing
1829
+ end
1830
+ it 'should support `min_trailing.equals(:another_view[, :trailing])`' do
1831
+ @layout.context(NSView.new) do
1832
+ @layout.constraints do
1833
+ @constraint = @layout.min_trailing.equals(:another_view)
1834
+ end
1835
+ end
1836
+ @constraint.constant.should == 0
1837
+ @constraint.relationship.should == :gte
1838
+ @constraint.multiplier.should == 1
1839
+ @constraint.relative_to.should == :another_view
1840
+ @constraint.attribute.should == :trailing
1841
+ @constraint.attribute2.should == :trailing
1842
+ end
1843
+ it 'should support `max_trailing.equals(:another_view[, :trailing])`' do
1844
+ @layout.context(NSView.new) do
1845
+ @layout.constraints do
1846
+ @constraint = @layout.max_trailing.equals(:another_view)
1847
+ end
1848
+ end
1849
+ @constraint.constant.should == 0
1850
+ @constraint.relationship.should == :lte
1851
+ @constraint.multiplier.should == 1
1852
+ @constraint.relative_to.should == :another_view
1853
+ @constraint.attribute.should == :trailing
1854
+ @constraint.attribute2.should == :trailing
1855
+ end
1856
+ it 'should support `trailing.equals(:another_view).plus(10)`' do
1857
+ @layout.context(NSView.new) do
1858
+ @layout.constraints do
1859
+ @constraint = @layout.trailing.equals(:another_view).plus(10)
1860
+ end
1861
+ end
1862
+ @constraint.constant.should == 10
1863
+ @constraint.relationship.should == :equal
1864
+ @constraint.multiplier.should == 1
1865
+ @constraint.relative_to.should == :another_view
1866
+ @constraint.attribute.should == :trailing
1867
+ @constraint.attribute2.should == :trailing
1868
+ end
1869
+ it 'should support `min_trailing.equals(:another_view).plus(10)`' do
1870
+ @layout.context(NSView.new) do
1871
+ @layout.constraints do
1872
+ @constraint = @layout.min_trailing.equals(:another_view).plus(10)
1873
+ end
1874
+ end
1875
+ @constraint.constant.should == 10
1876
+ @constraint.relationship.should == :gte
1877
+ @constraint.multiplier.should == 1
1878
+ @constraint.relative_to.should == :another_view
1879
+ @constraint.attribute.should == :trailing
1880
+ @constraint.attribute2.should == :trailing
1881
+ end
1882
+ it 'should support `max_trailing.equals(:another_view).plus(10)`' do
1883
+ @layout.context(NSView.new) do
1884
+ @layout.constraints do
1885
+ @constraint = @layout.max_trailing.equals(:another_view).plus(10)
1886
+ end
1887
+ end
1888
+ @constraint.constant.should == 10
1889
+ @constraint.relationship.should == :lte
1890
+ @constraint.multiplier.should == 1
1891
+ @constraint.relative_to.should == :another_view
1892
+ @constraint.attribute.should == :trailing
1893
+ @constraint.attribute2.should == :trailing
1894
+ end
1895
+ it 'should support `trailing.equals(:another_view).times(2).plus(10)`' do
1896
+ @layout.context(NSView.new) do
1897
+ @layout.constraints do
1898
+ @constraint = @layout.trailing.equals(:another_view).times(2).plus(10)
1899
+ end
1900
+ end
1901
+ @constraint.constant.should == 10
1902
+ @constraint.relationship.should == :equal
1903
+ @constraint.multiplier.should == 2
1904
+ @constraint.relative_to.should == :another_view
1905
+ @constraint.attribute.should == :trailing
1906
+ @constraint.attribute2.should == :trailing
1907
+ end
1908
+ it 'should support `min_trailing.equals(:another_view).times(2).plus(10)`' do
1909
+ @layout.context(NSView.new) do
1910
+ @layout.constraints do
1911
+ @constraint = @layout.min_trailing.equals(:another_view).times(2).plus(10)
1912
+ end
1913
+ end
1914
+ @constraint.constant.should == 10
1915
+ @constraint.relationship.should == :gte
1916
+ @constraint.multiplier.should == 2
1917
+ @constraint.relative_to.should == :another_view
1918
+ @constraint.attribute.should == :trailing
1919
+ @constraint.attribute2.should == :trailing
1920
+ end
1921
+ it 'should support `max_trailing.equals(:another_view).times(2).plus(10)`' do
1922
+ @layout.context(NSView.new) do
1923
+ @layout.constraints do
1924
+ @constraint = @layout.max_trailing.equals(:another_view).times(2).plus(10)
1925
+ end
1926
+ end
1927
+ @constraint.constant.should == 10
1928
+ @constraint.relationship.should == :lte
1929
+ @constraint.multiplier.should == 2
1930
+ @constraint.relative_to.should == :another_view
1931
+ @constraint.attribute.should == :trailing
1932
+ @constraint.attribute2.should == :trailing
1933
+ end
1934
+ end
1935
+
1936
+ describe '`baseline` support' do
1937
+ it 'should support `baseline 10`' do
1938
+ @layout.context(NSView.new) do
1939
+ @layout.constraints do
1940
+ @constraint = @layout.baseline(10)
1941
+ end
1942
+ end
1943
+ @constraint.constant.should == 10
1944
+ @constraint.relationship.should == :equal
1945
+ @constraint.multiplier.should == 1
1946
+ @constraint.relative_to.should == :superview
1947
+ @constraint.attribute.should == :baseline
1948
+ @constraint.attribute2.should == :baseline
1949
+ end
1950
+ it 'should support `min_baseline 10`' do
1951
+ @layout.context(NSView.new) do
1952
+ @layout.constraints do
1953
+ @constraint = @layout.min_baseline(10)
1954
+ end
1955
+ end
1956
+ @constraint.constant.should == 10
1957
+ @constraint.relationship.should == :gte
1958
+ @constraint.multiplier.should == 1
1959
+ @constraint.relative_to.should == :superview
1960
+ @constraint.attribute.should == :baseline
1961
+ @constraint.attribute2.should == :baseline
1962
+ end
1963
+ it 'should support `max_baseline 10`' do
1964
+ @layout.context(NSView.new) do
1965
+ @layout.constraints do
1966
+ @constraint = @layout.max_baseline(10)
1967
+ end
1968
+ end
1969
+ @constraint.constant.should == 10
1970
+ @constraint.relationship.should == :lte
1971
+ @constraint.multiplier.should == 1
1972
+ @constraint.relative_to.should == :superview
1973
+ @constraint.attribute.should == :baseline
1974
+ @constraint.attribute2.should == :baseline
1975
+ end
1976
+ it 'should support `baseline.equals(:another_view[, :baseline])`' do
1977
+ @layout.context(NSView.new) do
1978
+ @layout.constraints do
1979
+ @constraint = @layout.baseline.equals(:another_view)
1980
+ end
1981
+ end
1982
+ @constraint.constant.should == 0
1983
+ @constraint.relationship.should == :equal
1984
+ @constraint.multiplier.should == 1
1985
+ @constraint.relative_to.should == :another_view
1986
+ @constraint.attribute.should == :baseline
1987
+ @constraint.attribute2.should == :baseline
1988
+ end
1989
+ it 'should support `min_baseline.equals(:another_view[, :baseline])`' do
1990
+ @layout.context(NSView.new) do
1991
+ @layout.constraints do
1992
+ @constraint = @layout.min_baseline.equals(:another_view)
1993
+ end
1994
+ end
1995
+ @constraint.constant.should == 0
1996
+ @constraint.relationship.should == :gte
1997
+ @constraint.multiplier.should == 1
1998
+ @constraint.relative_to.should == :another_view
1999
+ @constraint.attribute.should == :baseline
2000
+ @constraint.attribute2.should == :baseline
2001
+ end
2002
+ it 'should support `max_baseline.equals(:another_view[, :baseline])`' do
2003
+ @layout.context(NSView.new) do
2004
+ @layout.constraints do
2005
+ @constraint = @layout.max_baseline.equals(:another_view)
2006
+ end
2007
+ end
2008
+ @constraint.constant.should == 0
2009
+ @constraint.relationship.should == :lte
2010
+ @constraint.multiplier.should == 1
2011
+ @constraint.relative_to.should == :another_view
2012
+ @constraint.attribute.should == :baseline
2013
+ @constraint.attribute2.should == :baseline
2014
+ end
2015
+ it 'should support `baseline.equals(:another_view).plus(10)`' do
2016
+ @layout.context(NSView.new) do
2017
+ @layout.constraints do
2018
+ @constraint = @layout.baseline.equals(:another_view).plus(10)
2019
+ end
2020
+ end
2021
+ @constraint.constant.should == 10
2022
+ @constraint.relationship.should == :equal
2023
+ @constraint.multiplier.should == 1
2024
+ @constraint.relative_to.should == :another_view
2025
+ @constraint.attribute.should == :baseline
2026
+ @constraint.attribute2.should == :baseline
2027
+ end
2028
+ it 'should support `min_baseline.equals(:another_view).plus(10)`' do
2029
+ @layout.context(NSView.new) do
2030
+ @layout.constraints do
2031
+ @constraint = @layout.min_baseline.equals(:another_view).plus(10)
2032
+ end
2033
+ end
2034
+ @constraint.constant.should == 10
2035
+ @constraint.relationship.should == :gte
2036
+ @constraint.multiplier.should == 1
2037
+ @constraint.relative_to.should == :another_view
2038
+ @constraint.attribute.should == :baseline
2039
+ @constraint.attribute2.should == :baseline
2040
+ end
2041
+ it 'should support `max_baseline.equals(:another_view).plus(10)`' do
2042
+ @layout.context(NSView.new) do
2043
+ @layout.constraints do
2044
+ @constraint = @layout.max_baseline.equals(:another_view).plus(10)
2045
+ end
2046
+ end
2047
+ @constraint.constant.should == 10
2048
+ @constraint.relationship.should == :lte
2049
+ @constraint.multiplier.should == 1
2050
+ @constraint.relative_to.should == :another_view
2051
+ @constraint.attribute.should == :baseline
2052
+ @constraint.attribute2.should == :baseline
2053
+ end
2054
+ it 'should support `baseline.equals(:another_view).times(2).plus(10)`' do
2055
+ @layout.context(NSView.new) do
2056
+ @layout.constraints do
2057
+ @constraint = @layout.baseline.equals(:another_view).times(2).plus(10)
2058
+ end
2059
+ end
2060
+ @constraint.constant.should == 10
2061
+ @constraint.relationship.should == :equal
2062
+ @constraint.multiplier.should == 2
2063
+ @constraint.relative_to.should == :another_view
2064
+ @constraint.attribute.should == :baseline
2065
+ @constraint.attribute2.should == :baseline
2066
+ end
2067
+ it 'should support `min_baseline.equals(:another_view).times(2).plus(10)`' do
2068
+ @layout.context(NSView.new) do
2069
+ @layout.constraints do
2070
+ @constraint = @layout.min_baseline.equals(:another_view).times(2).plus(10)
2071
+ end
2072
+ end
2073
+ @constraint.constant.should == 10
2074
+ @constraint.relationship.should == :gte
2075
+ @constraint.multiplier.should == 2
2076
+ @constraint.relative_to.should == :another_view
2077
+ @constraint.attribute.should == :baseline
2078
+ @constraint.attribute2.should == :baseline
2079
+ end
2080
+ it 'should support `max_baseline.equals(:another_view).times(2).plus(10)`' do
2081
+ @layout.context(NSView.new) do
2082
+ @layout.constraints do
2083
+ @constraint = @layout.max_baseline.equals(:another_view).times(2).plus(10)
2084
+ end
2085
+ end
2086
+ @constraint.constant.should == 10
2087
+ @constraint.relationship.should == :lte
2088
+ @constraint.multiplier.should == 2
2089
+ @constraint.relative_to.should == :another_view
2090
+ @constraint.attribute.should == :baseline
2091
+ @constraint.attribute2.should == :baseline
2092
+ end
2093
+ end
2094
+
2095
+ end