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,362 @@
1
+ describe 'Size constraints helpers' do
2
+
3
+ before do
4
+ @layout = MK::Layout.new
5
+ @constraint = nil
6
+ @view = nil
7
+ @another_view = nil
8
+ end
9
+
10
+ it 'should support `size 10`' do
11
+ @layout.context(NSView.new) do
12
+ @layout.constraints do
13
+ @constraint = @layout.size(10)
14
+ end
15
+ end
16
+ @constraint.constant.should == [10, 10]
17
+ @constraint.relationship.should == :equal
18
+ @constraint.multiplier.should == [1, 1]
19
+ @constraint.relative_to.should == nil
20
+ @constraint.attribute.should == [:width, :height]
21
+ @constraint.attribute2.should == [:width, :height]
22
+ end
23
+ it 'should support `min_size 10`' do
24
+ @layout.context(NSView.new) do
25
+ @layout.constraints do
26
+ @constraint = @layout.min_size(10)
27
+ end
28
+ end
29
+ @constraint.constant.should == [10, 10]
30
+ @constraint.relationship.should == :gte
31
+ @constraint.multiplier.should == [1, 1]
32
+ @constraint.relative_to.should == nil
33
+ @constraint.attribute.should == [:width, :height]
34
+ @constraint.attribute2.should == [:width, :height]
35
+ end
36
+ it 'should support `max_size 10`' do
37
+ @layout.context(NSView.new) do
38
+ @layout.constraints do
39
+ @constraint = @layout.max_size(10)
40
+ end
41
+ end
42
+ @constraint.constant.should == [10, 10]
43
+ @constraint.relationship.should == :lte
44
+ @constraint.multiplier.should == [1, 1]
45
+ @constraint.relative_to.should == nil
46
+ @constraint.attribute.should == [:width, :height]
47
+ @constraint.attribute2.should == [:width, :height]
48
+ end
49
+ it 'should support `size [10, 10]`' do
50
+ @layout.context(NSView.new) do
51
+ @layout.constraints do
52
+ @constraint = @layout.size([10, 10])
53
+ end
54
+ end
55
+ @constraint.constant.should == [10, 10]
56
+ @constraint.relationship.should == :equal
57
+ @constraint.multiplier.should == [1, 1]
58
+ @constraint.relative_to.should == nil
59
+ @constraint.attribute.should == [:width, :height]
60
+ @constraint.attribute2.should == [:width, :height]
61
+ end
62
+ it 'should support `min_size [10, 10]`' do
63
+ @layout.context(NSView.new) do
64
+ @layout.constraints do
65
+ @constraint = @layout.min_size([10, 10])
66
+ end
67
+ end
68
+ @constraint.constant.should == [10, 10]
69
+ @constraint.relationship.should == :gte
70
+ @constraint.multiplier.should == [1, 1]
71
+ @constraint.relative_to.should == nil
72
+ @constraint.attribute.should == [:width, :height]
73
+ @constraint.attribute2.should == [:width, :height]
74
+ end
75
+ it 'should support `max_size [10, 10]`' do
76
+ @layout.context(NSView.new) do
77
+ @layout.constraints do
78
+ @constraint = @layout.max_size([10, 10])
79
+ end
80
+ end
81
+ @constraint.constant.should == [10, 10]
82
+ @constraint.relationship.should == :lte
83
+ @constraint.multiplier.should == [1, 1]
84
+ @constraint.relative_to.should == nil
85
+ @constraint.attribute.should == [:width, :height]
86
+ @constraint.attribute2.should == [:width, :height]
87
+ end
88
+ it 'should support `size w: 10, h: 10`' do
89
+ @layout.context(NSView.new) do
90
+ @layout.constraints do
91
+ @constraint = @layout.size(w: 10, h: 10)
92
+ end
93
+ end
94
+ @constraint.constant.should == [10, 10]
95
+ @constraint.relationship.should == :equal
96
+ @constraint.multiplier.should == [1, 1]
97
+ @constraint.relative_to.should == nil
98
+ @constraint.attribute.should == [:width, :height]
99
+ @constraint.attribute2.should == [:width, :height]
100
+ end
101
+ it 'should support `min_size w: 10, h: 10`' do
102
+ @layout.context(NSView.new) do
103
+ @layout.constraints do
104
+ @constraint = @layout.min_size(w: 10, h: 10)
105
+ end
106
+ end
107
+ @constraint.constant.should == [10, 10]
108
+ @constraint.relationship.should == :gte
109
+ @constraint.multiplier.should == [1, 1]
110
+ @constraint.relative_to.should == nil
111
+ @constraint.attribute.should == [:width, :height]
112
+ @constraint.attribute2.should == [:width, :height]
113
+ end
114
+ it 'should support `max_size w: 10, h: 10`' do
115
+ @layout.context(NSView.new) do
116
+ @layout.constraints do
117
+ @constraint = @layout.max_size(w: 10, h: 10)
118
+ end
119
+ end
120
+ @constraint.constant.should == [10, 10]
121
+ @constraint.relationship.should == :lte
122
+ @constraint.multiplier.should == [1, 1]
123
+ @constraint.relative_to.should == nil
124
+ @constraint.attribute.should == [:width, :height]
125
+ @constraint.attribute2.should == [:width, :height]
126
+ end
127
+ it 'should support `size.equals(:another_view[, :size])`' do
128
+ @layout.context(NSView.new) do
129
+ @layout.constraints do
130
+ @constraint = @layout.size.equals(:another_view)
131
+ end
132
+ end
133
+ @constraint.constant.should == [0, 0]
134
+ @constraint.relationship.should == :equal
135
+ @constraint.multiplier.should == [1, 1]
136
+ @constraint.relative_to.should == :another_view
137
+ @constraint.attribute.should == [:width, :height]
138
+ @constraint.attribute2.should == [:width, :height]
139
+ end
140
+ it 'should support `size.equals(:another_view).plus(10).plus([5, 10])`' do
141
+ @layout.context(NSView.new) do
142
+ @layout.constraints do
143
+ @constraint = @layout.size.equals(:another_view).plus(10).plus([5, 10])
144
+ end
145
+ end
146
+ @constraint.constant.should == [15, 20]
147
+ @constraint.relationship.should == :equal
148
+ @constraint.multiplier.should == [1, 1]
149
+ @constraint.relative_to.should == :another_view
150
+ @constraint.attribute.should == [:width, :height]
151
+ @constraint.attribute2.should == [:width, :height]
152
+ end
153
+ it 'should support `min_size.equals(:another_view[, :size])`' do
154
+ @layout.context(NSView.new) do
155
+ @layout.constraints do
156
+ @constraint = @layout.min_size.equals(:another_view)
157
+ end
158
+ end
159
+ @constraint.constant.should == [0, 0]
160
+ @constraint.relationship.should == :gte
161
+ @constraint.multiplier.should == [1, 1]
162
+ @constraint.relative_to.should == :another_view
163
+ @constraint.attribute.should == [:width, :height]
164
+ @constraint.attribute2.should == [:width, :height]
165
+ end
166
+ it 'should support `max_size.equals(:another_view[, :size])`' do
167
+ @layout.context(NSView.new) do
168
+ @layout.constraints do
169
+ @constraint = @layout.max_size.equals(:another_view)
170
+ end
171
+ end
172
+ @constraint.constant.should == [0, 0]
173
+ @constraint.relationship.should == :lte
174
+ @constraint.multiplier.should == [1, 1]
175
+ @constraint.relative_to.should == :another_view
176
+ @constraint.attribute.should == [:width, :height]
177
+ @constraint.attribute2.should == [:width, :height]
178
+ end
179
+ it 'should support `size.equals(:another_view).plus(10)`' do
180
+ @layout.context(NSView.new) do
181
+ @layout.constraints do
182
+ @constraint = @layout.size.equals(:another_view).plus(10)
183
+ end
184
+ end
185
+ @constraint.constant.should == [10, 10]
186
+ @constraint.relationship.should == :equal
187
+ @constraint.multiplier.should == [1, 1]
188
+ @constraint.relative_to.should == :another_view
189
+ @constraint.attribute.should == [:width, :height]
190
+ @constraint.attribute2.should == [:width, :height]
191
+ end
192
+ it 'should support `min_size.equals(:another_view).plus(10)`' do
193
+ @layout.context(NSView.new) do
194
+ @layout.constraints do
195
+ @constraint = @layout.min_size.equals(:another_view).plus(10)
196
+ end
197
+ end
198
+ @constraint.constant.should == [10, 10]
199
+ @constraint.relationship.should == :gte
200
+ @constraint.multiplier.should == [1, 1]
201
+ @constraint.relative_to.should == :another_view
202
+ @constraint.attribute.should == [:width, :height]
203
+ @constraint.attribute2.should == [:width, :height]
204
+ end
205
+ it 'should support `max_size.equals(:another_view).plus(10)`' do
206
+ @layout.context(NSView.new) do
207
+ @layout.constraints do
208
+ @constraint = @layout.max_size.equals(:another_view).plus(10)
209
+ end
210
+ end
211
+ @constraint.constant.should == [10, 10]
212
+ @constraint.relationship.should == :lte
213
+ @constraint.multiplier.should == [1, 1]
214
+ @constraint.relative_to.should == :another_view
215
+ @constraint.attribute.should == [:width, :height]
216
+ @constraint.attribute2.should == [:width, :height]
217
+ end
218
+ it 'should support `size.equals(:another_view).plus([10, 10])`' do
219
+ @layout.context(NSView.new) do
220
+ @layout.constraints do
221
+ @constraint = @layout.size.equals(:another_view).plus([10, 10])
222
+ end
223
+ end
224
+ @constraint.constant.should == [10, 10]
225
+ @constraint.relationship.should == :equal
226
+ @constraint.multiplier.should == [1, 1]
227
+ @constraint.relative_to.should == :another_view
228
+ @constraint.attribute.should == [:width, :height]
229
+ @constraint.attribute2.should == [:width, :height]
230
+ end
231
+ it 'should support `min_size.equals(:another_view).plus([10, 10])`' do
232
+ @layout.context(NSView.new) do
233
+ @layout.constraints do
234
+ @constraint = @layout.min_size.equals(:another_view).plus([10, 10])
235
+ end
236
+ end
237
+ @constraint.constant.should == [10, 10]
238
+ @constraint.relationship.should == :gte
239
+ @constraint.multiplier.should == [1, 1]
240
+ @constraint.relative_to.should == :another_view
241
+ @constraint.attribute.should == [:width, :height]
242
+ @constraint.attribute2.should == [:width, :height]
243
+ end
244
+ it 'should support `max_size.equals(:another_view).plus(w: 10, h: 10)`' do
245
+ @layout.context(NSView.new) do
246
+ @layout.constraints do
247
+ @constraint = @layout.max_size.equals(:another_view).plus(w: 10, h: 10)
248
+ end
249
+ end
250
+ @constraint.constant.should == [10, 10]
251
+ @constraint.relationship.should == :lte
252
+ @constraint.multiplier.should == [1, 1]
253
+ @constraint.relative_to.should == :another_view
254
+ @constraint.attribute.should == [:width, :height]
255
+ @constraint.attribute2.should == [:width, :height]
256
+ end
257
+ it 'should support `size.equals(:another_view).times(2).plus(10)`' do
258
+ @layout.context(NSView.new) do
259
+ @layout.constraints do
260
+ @constraint = @layout.size.equals(:another_view).times(2).plus(10)
261
+ end
262
+ end
263
+ @constraint.constant.should == [10, 10]
264
+ @constraint.relationship.should == :equal
265
+ @constraint.multiplier.should == [2, 2]
266
+ @constraint.relative_to.should == :another_view
267
+ @constraint.attribute.should == [:width, :height]
268
+ @constraint.attribute2.should == [:width, :height]
269
+ end
270
+ it 'should support `min_size.equals(:another_view).times(2).plus(10)`' do
271
+ @layout.context(NSView.new) do
272
+ @layout.constraints do
273
+ @constraint = @layout.min_size.equals(:another_view).times(2).plus(10)
274
+ end
275
+ end
276
+ @constraint.constant.should == [10, 10]
277
+ @constraint.relationship.should == :gte
278
+ @constraint.multiplier.should == [2, 2]
279
+ @constraint.relative_to.should == :another_view
280
+ @constraint.attribute.should == [:width, :height]
281
+ @constraint.attribute2.should == [:width, :height]
282
+ end
283
+ it 'should support `max_size.equals(:another_view).times(2).plus(10)`' do
284
+ @layout.context(NSView.new) do
285
+ @layout.constraints do
286
+ @constraint = @layout.max_size.equals(:another_view).times(2).plus(10)
287
+ end
288
+ end
289
+ @constraint.constant.should == [10, 10]
290
+ @constraint.relationship.should == :lte
291
+ @constraint.multiplier.should == [2, 2]
292
+ @constraint.relative_to.should == :another_view
293
+ @constraint.attribute.should == [:width, :height]
294
+ @constraint.attribute2.should == [:width, :height]
295
+ end
296
+ it 'should support `size.equals(:another_view).times([2, 2]).plus(10)`' do
297
+ @layout.context(NSView.new) do
298
+ @layout.constraints do
299
+ @constraint = @layout.size.equals(:another_view).times([2, 2]).plus(10)
300
+ end
301
+ end
302
+ @constraint.constant.should == [10, 10]
303
+ @constraint.relationship.should == :equal
304
+ @constraint.multiplier.should == [2, 2]
305
+ @constraint.relative_to.should == :another_view
306
+ @constraint.attribute.should == [:width, :height]
307
+ @constraint.attribute2.should == [:width, :height]
308
+ end
309
+ it 'should support `min_size.equals(:another_view).times([2, 2]).plus(10)`' do
310
+ @layout.context(NSView.new) do
311
+ @layout.constraints do
312
+ @constraint = @layout.min_size.equals(:another_view).times([2, 2]).plus(10)
313
+ end
314
+ end
315
+ @constraint.constant.should == [10, 10]
316
+ @constraint.relationship.should == :gte
317
+ @constraint.multiplier.should == [2, 2]
318
+ @constraint.relative_to.should == :another_view
319
+ @constraint.attribute.should == [:width, :height]
320
+ @constraint.attribute2.should == [:width, :height]
321
+ end
322
+ it 'should support `max_size.equals(:another_view).times(w: 2, h: 2).plus(10)`' do
323
+ @layout.context(NSView.new) do
324
+ @layout.constraints do
325
+ @constraint = @layout.max_size.equals(:another_view).times(w: 2, h: 2).plus(10)
326
+ end
327
+ end
328
+ @constraint.constant.should == [10, 10]
329
+ @constraint.relationship.should == :lte
330
+ @constraint.multiplier.should == [2, 2]
331
+ @constraint.relative_to.should == :another_view
332
+ @constraint.attribute.should == [:width, :height]
333
+ @constraint.attribute2.should == [:width, :height]
334
+ end
335
+ it 'should support `size.equals(:another_view).times(2).times([3, 4])`' do
336
+ @layout.context(NSView.new) do
337
+ @layout.constraints do
338
+ @constraint = @layout.size.equals(:another_view).times(2).times([3, 4])
339
+ end
340
+ end
341
+ @constraint.constant.should == [0, 0]
342
+ @constraint.relationship.should == :equal
343
+ @constraint.multiplier.should == [6, 8]
344
+ @constraint.relative_to.should == :another_view
345
+ @constraint.attribute.should == [:width, :height]
346
+ @constraint.attribute2.should == [:width, :height]
347
+ end
348
+ it 'should support `size.equals(:another_view).divided_by(2)`' do
349
+ @layout.context(NSView.new) do
350
+ @layout.constraints do
351
+ @constraint = @layout.size.equals(:another_view).divided_by(2)
352
+ end
353
+ end
354
+ @constraint.constant.should == [0, 0]
355
+ @constraint.relationship.should == :equal
356
+ @constraint.multiplier.should == [0.5, 0.5]
357
+ @constraint.relative_to.should == :another_view
358
+ @constraint.attribute.should == [:width, :height]
359
+ @constraint.attribute2.should == [:width, :height]
360
+ end
361
+
362
+ end
@@ -0,0 +1,14 @@
1
+ describe TestCreateMenu do
2
+
3
+ before do
4
+ @subject = TestCreateMenu.new
5
+ end
6
+
7
+ it 'should create a menu via "create"' do
8
+ menu = @subject.some_menu
9
+ menu.should.not == nil
10
+ menu.should.be.kind_of(NSMenu)
11
+ menu.title.should == 'Test Create'
12
+ end
13
+
14
+ end
@@ -0,0 +1,63 @@
1
+ describe TestCreateViaExtensionsMenu do
2
+
3
+ before do
4
+ @subject = TestCreateViaExtensionsMenu.new
5
+ end
6
+
7
+ it 'should have four items' do
8
+ @subject.menu.itemArray.length.should == 4
9
+ end
10
+
11
+ it 'should have an application menu item' do
12
+ app_item = @subject.menu.itemArray[0]
13
+ app_item.should.not == nil
14
+ app_item.should.be.kind_of(NSMenuItem)
15
+ app_item.title.should == 'MotionKit'
16
+ end
17
+
18
+ it 'should have an application menu item with submenu' do
19
+ app_item = @subject.menu.itemArray[0]
20
+ app_menu = app_item.submenu
21
+ app_menu.itemArray.length.should > 0
22
+ end
23
+
24
+ it 'should have a file menu item' do
25
+ file_item = @subject.menu.itemArray[1]
26
+ file_item.should.not == nil
27
+ file_item.should.be.kind_of(NSMenuItem)
28
+ file_item.title.should == 'File'
29
+ end
30
+
31
+ it 'should have a file menu item with submenu' do
32
+ file_item = @subject.menu.itemArray[1]
33
+ file_menu = file_item.submenu
34
+ file_menu.itemArray.length.should > 0
35
+ end
36
+
37
+ it 'should have a window menu item' do
38
+ window_item = @subject.menu.itemArray[2]
39
+ window_item.should.not == nil
40
+ window_item.should.be.kind_of(NSMenuItem)
41
+ window_item.title.should == 'Window'
42
+ end
43
+
44
+ it 'should have a window menu item with submenu' do
45
+ window_item = @subject.menu.itemArray[2]
46
+ window_menu = window_item.submenu
47
+ window_menu.itemArray.length.should > 0
48
+ end
49
+
50
+ it 'should have a help menu item' do
51
+ help_item = @subject.menu.itemArray[3]
52
+ help_item.should.not == nil
53
+ help_item.should.be.kind_of(NSMenuItem)
54
+ help_item.title.should == 'Help'
55
+ end
56
+
57
+ it 'should have a help menu item with submenu' do
58
+ help_item = @subject.menu.itemArray[3]
59
+ help_menu = help_item.submenu
60
+ help_menu.itemArray.length.should > 0
61
+ end
62
+
63
+ end
@@ -0,0 +1,85 @@
1
+ describe TestDeferredLayout do
2
+
3
+ before do
4
+ @layout = TestDeferredLayout.new
5
+ @layout.view
6
+ end
7
+
8
+ describe 'from layout' do
9
+ it 'should run the deferred block' do
10
+ @layout.layout_test_ran.should == true
11
+ end
12
+
13
+ it 'should have assigned the value 0' do
14
+ @layout.layout_test_is_0.should == true
15
+ end
16
+
17
+ it 'should end up with the value 1' do
18
+ @layout.layout_test.should == 1
19
+ end
20
+ end
21
+
22
+ describe 'from create_view' do
23
+ before do
24
+ @layout.create_view
25
+ end
26
+
27
+ it 'should run the deferred block' do
28
+ @layout.create_view_test_ran.should == true
29
+ end
30
+
31
+ it 'should have assigned the value 0' do
32
+ @layout.create_view_test_is_0.should == true
33
+ end
34
+
35
+ it 'should end up with the value 1' do
36
+ @layout.create_view_test.should == 1
37
+ end
38
+ end
39
+
40
+ describe 'from error_no_context' do
41
+ it 'should raise InvalidDeferredError' do
42
+ -> do
43
+ @layout.error_no_context
44
+ end.should.raise(MK::InvalidDeferredError)
45
+ end
46
+ end
47
+
48
+ describe 'from nested_blocks' do
49
+ before do
50
+ @layout.nested_blocks
51
+ end
52
+
53
+ it 'should run the deferred block' do
54
+ @layout.nested_blocks_test_ran.should == true
55
+ end
56
+ it 'should have assigned the value 0' do
57
+ @layout.nested_blocks_test_is_0.should == true
58
+ end
59
+ it 'should have assigned the value 1' do
60
+ @layout.nested_blocks_test_is_1.should == true
61
+ end
62
+ it 'should end up with the value 1' do
63
+ @layout.nested_blocks_test.should == 2
64
+ end
65
+ end
66
+
67
+ describe 'from apply_layouts' do
68
+ before do
69
+ @layout.apply_layouts
70
+ end
71
+
72
+ it 'should run the deferred block' do
73
+ @layout.apply_layouts_test_ran.should == 2
74
+ end
75
+
76
+ it 'should have assigned text to the label' do
77
+ @layout.apply_layouts_label.stringValue.should == 'after'
78
+ end
79
+
80
+ it 'should have assigned opacity to the layer' do
81
+ @layout.apply_layouts_layer.opacity.should == 0.5
82
+ end
83
+ end
84
+
85
+ end