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.
- checksums.yaml +7 -0
- data/README.md +839 -0
- data/lib/motion-kit-cocoa/cocoa_util.rb +59 -0
- data/lib/motion-kit-cocoa/constraints/constraint.rb +765 -0
- data/lib/motion-kit-cocoa/constraints/constraint_placeholder.rb +22 -0
- data/lib/motion-kit-cocoa/constraints/constraints_layout.rb +536 -0
- data/lib/motion-kit-cocoa/constraints/constraints_target.rb +52 -0
- data/lib/motion-kit-cocoa/layouts/cagradientlayer_layout.rb +13 -0
- data/lib/motion-kit-cocoa/layouts/calayer_layout.rb +27 -0
- data/lib/motion-kit-cocoa/layouts/sugarcube_compat.rb +38 -0
- data/lib/motion-kit-ios/dummy.rb +93 -0
- data/lib/motion-kit-ios/ios_util.rb +20 -0
- data/lib/motion-kit-ios/layouts/constraints_layout.rb +22 -0
- data/lib/motion-kit-ios/layouts/layout_device.rb +32 -0
- data/lib/motion-kit-ios/layouts/layout_orientation.rb +47 -0
- data/lib/motion-kit-ios/layouts/uibutton_layout.rb +52 -0
- data/lib/motion-kit-ios/layouts/uiview_layout.rb +45 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_autoresizing.rb +75 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_constraints.rb +36 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_frame.rb +307 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_gradient.rb +20 -0
- data/lib/motion-kit-osx/dummy.rb +89 -0
- data/lib/motion-kit-osx/layouts/constraints_layout.rb +42 -0
- data/lib/motion-kit-osx/layouts/nsmenu_extensions.rb +186 -0
- data/lib/motion-kit-osx/layouts/nsmenu_layout.rb +109 -0
- data/lib/motion-kit-osx/layouts/nsmenuitem_extensions.rb +45 -0
- data/lib/motion-kit-osx/layouts/nstablecolumn_layout.rb +12 -0
- data/lib/motion-kit-osx/layouts/nstableview_layout.rb +20 -0
- data/lib/motion-kit-osx/layouts/nsview_layout.rb +47 -0
- data/lib/motion-kit-osx/layouts/nsview_layout_autoresizing.rb +75 -0
- data/lib/motion-kit-osx/layouts/nsview_layout_constraints.rb +34 -0
- data/lib/motion-kit-osx/layouts/nsview_layout_frame.rb +375 -0
- data/lib/motion-kit-osx/layouts/nswindow_frame.rb +14 -0
- data/lib/motion-kit-osx/layouts/nswindow_layout.rb +77 -0
- data/lib/motion-kit-osx/osx_util.rb +16 -0
- data/lib/motion-kit.rb +33 -0
- data/lib/motion-kit/calculate.rb +263 -0
- data/lib/motion-kit/layouts/base_layout.rb +299 -0
- data/lib/motion-kit/layouts/base_layout_class_methods.rb +43 -0
- data/lib/motion-kit/layouts/parent.rb +68 -0
- data/lib/motion-kit/layouts/view_layout.rb +327 -0
- data/lib/motion-kit/motion-kit.rb +18 -0
- data/lib/motion-kit/object.rb +16 -0
- data/lib/motion-kit/util.rb +20 -0
- data/lib/motion-kit/version.rb +1 -1
- data/spec/ios/apply_styles_spec.rb +21 -0
- data/spec/ios/autoresizing_helper_spec.rb +224 -0
- data/spec/ios/calculate_spec.rb +322 -0
- data/spec/ios/calculator_spec.rb +31 -0
- data/spec/ios/constraints_helpers/attribute_lookup_spec.rb +27 -0
- data/spec/ios/constraints_helpers/axis_lookup_spec.rb +13 -0
- data/spec/ios/constraints_helpers/center_constraints_spec.rb +419 -0
- data/spec/ios/constraints_helpers/constraint_placeholder_spec.rb +72 -0
- data/spec/ios/constraints_helpers/priority_lookup_spec.rb +19 -0
- data/spec/ios/constraints_helpers/relationship_lookup_spec.rb +27 -0
- data/spec/ios/constraints_helpers/relative_corners_spec.rb +274 -0
- data/spec/ios/constraints_helpers/relative_location_spec.rb +111 -0
- data/spec/ios/constraints_helpers/simple_constraints_spec.rb +2763 -0
- data/spec/ios/constraints_helpers/size_constraints_spec.rb +422 -0
- data/spec/ios/constraints_helpers/view_lookup_constraints_spec.rb +93 -0
- data/spec/ios/create_layout_spec.rb +40 -0
- data/spec/ios/custom_layout_spec.rb +13 -0
- data/spec/ios/deferred_spec.rb +89 -0
- data/spec/ios/device_helpers_spec.rb +51 -0
- data/spec/ios/frame_helper_spec.rb +1150 -0
- data/spec/ios/layer_layout_spec.rb +36 -0
- data/spec/ios/layout_extensions_spec.rb +70 -0
- data/spec/ios/layout_spec.rb +74 -0
- data/spec/ios/layout_state_spec.rb +27 -0
- data/spec/ios/motionkit_util_spec.rb +102 -0
- data/spec/ios/objc_selectors_spec.rb +10 -0
- data/spec/ios/orientation_helper_specs.rb +67 -0
- data/spec/ios/parent_layout_spec.rb +19 -0
- data/spec/ios/parent_spec.rb +45 -0
- data/spec/ios/remove_layout_spec.rb +25 -0
- data/spec/ios/root_layout_spec.rb +53 -0
- data/spec/ios/setters_spec.rb +63 -0
- data/spec/ios/uibutton_layout_spec.rb +24 -0
- data/spec/ios/uitextfield_spec.rb +14 -0
- data/spec/ios/view_attr_spec.rb +25 -0
- data/spec/osx/autoresizing_helper_spec.rb +224 -0
- data/spec/osx/constraints_helper_spec.rb +0 -0
- data/spec/osx/constraints_helpers/orientation_lookup_spec.rb +13 -0
- data/spec/osx/constraints_helpers/simple_constraints_spec.rb +2095 -0
- data/spec/osx/constraints_helpers/size_constraints_spec.rb +362 -0
- data/spec/osx/create_menu_spec.rb +14 -0
- data/spec/osx/create_via_extensions_spec.rb +63 -0
- data/spec/osx/deferred_spec.rb +85 -0
- data/spec/osx/frame_helper_spec.rb +1881 -0
- data/spec/osx/menu_extensions_spec.rb +376 -0
- data/spec/osx/menu_layout_spec.rb +157 -0
- data/spec/osx/menu_spec.rb +70 -0
- data/spec/osx/root_menu_spec.rb +15 -0
- metadata +166 -14
@@ -0,0 +1,376 @@
|
|
1
|
+
describe 'NSMenuLayout extensions' do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@subject = MK::NSMenuLayout.new
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should have an `app_name` method' do
|
8
|
+
@subject.app_name.should == 'MotionKit'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have an `app_menu` method' do
|
12
|
+
menu = @subject.app_menu
|
13
|
+
menu.should.be.kind_of(NSMenu)
|
14
|
+
menu.itemArray.length.should == 10
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should assign a title via `app_menu`' do
|
18
|
+
menu = @subject.app_menu('Title')
|
19
|
+
menu.title.should == 'Title'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should assign a title via options in `app_menu`' do
|
23
|
+
menu = @subject.app_menu(title: 'Title')
|
24
|
+
menu.title.should == 'Title'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should be able to exclude items from `app_menu`' do
|
28
|
+
menu = @subject.app_menu(exclude: [:about, :prefs])
|
29
|
+
menu.itemArray.length.should == 6
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should be able to exclude a single item from `app_menu`' do
|
33
|
+
menu = @subject.app_menu(exclude: :about)
|
34
|
+
menu.itemArray.length.should == 8
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
it 'should have a `file_menu` method' do
|
39
|
+
menu = @subject.file_menu
|
40
|
+
menu.should.be.kind_of(NSMenu)
|
41
|
+
menu.itemArray.length.should == 9
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have a default title via `file_menu`' do
|
45
|
+
menu = @subject.file_menu
|
46
|
+
menu.title.should == 'File'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should assign a title via `file_menu`' do
|
50
|
+
menu = @subject.file_menu('Title')
|
51
|
+
menu.title.should == 'Title'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should assign a title via options in `file_menu`' do
|
55
|
+
menu = @subject.file_menu(title: 'Title')
|
56
|
+
menu.title.should == 'Title'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should be able to exclude items from `file_menu`' do
|
60
|
+
menu = @subject.file_menu(exclude: [:new, :open])
|
61
|
+
menu.itemArray.length.should == 6
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should be able to exclude a single item from `file_menu`' do
|
65
|
+
menu = @subject.file_menu(exclude: :new)
|
66
|
+
menu.itemArray.length.should == 8
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
it 'should have a `window_menu` method' do
|
71
|
+
menu = @subject.window_menu
|
72
|
+
menu.should.be.kind_of(NSMenu)
|
73
|
+
menu.itemArray.length.should == 4
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should have a default title via `window_menu`' do
|
77
|
+
menu = @subject.window_menu
|
78
|
+
menu.title.should == 'Window'
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should assign a title via `window_menu`' do
|
82
|
+
menu = @subject.window_menu('Title')
|
83
|
+
menu.title.should == 'Title'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should assign a title via options in `window_menu`' do
|
87
|
+
menu = @subject.window_menu(title: 'Title')
|
88
|
+
menu.title.should == 'Title'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should be able to exclude items from `window_menu`' do
|
92
|
+
menu = @subject.window_menu(exclude: [:minimize, :zoom])
|
93
|
+
menu.itemArray.length.should == 1
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should be able to exclude a single item from `window_menu`' do
|
97
|
+
menu = @subject.window_menu(exclude: :minimize)
|
98
|
+
menu.itemArray.length.should == 3
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
it 'should have a `help_menu` method' do
|
103
|
+
menu = @subject.help_menu
|
104
|
+
menu.should.be.kind_of(NSMenu)
|
105
|
+
menu.itemArray.length.should == 1
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should have a default title via `help_menu`' do
|
109
|
+
menu = @subject.help_menu
|
110
|
+
menu.title.should == 'Help'
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should assign a title via `help_menu`' do
|
114
|
+
menu = @subject.help_menu('Title')
|
115
|
+
menu.title.should == 'Title'
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should assign a title via options in `help_menu`' do
|
119
|
+
menu = @subject.help_menu(title: 'Title')
|
120
|
+
menu.title.should == 'Title'
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
it 'should have a `separator_item` method' do
|
125
|
+
item = @subject.separator_item
|
126
|
+
item.should.be.kind_of(NSMenuItem)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should have a `about_item` method' do
|
130
|
+
item = @subject.about_item
|
131
|
+
item.should.be.kind_of(NSMenuItem)
|
132
|
+
item.keyEquivalent.should == ''
|
133
|
+
item.action.should == 'orderFrontStandardAboutPanel:'.to_sym
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should have a `about_item` method with options' do
|
137
|
+
item = @subject.about_item(key: 'a', action: 'action:')
|
138
|
+
item.keyEquivalent.should == 'a'
|
139
|
+
item.action.should == 'action:'.to_sym
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should have a `preferences_item` method' do
|
143
|
+
item = @subject.preferences_item
|
144
|
+
item.should.be.kind_of(NSMenuItem)
|
145
|
+
item.keyEquivalent.should == ','
|
146
|
+
item.action.should == 'openPreferences:'.to_sym
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should have a `preferences_item` method with options' do
|
150
|
+
item = @subject.preferences_item(key: 'a', action: 'action:')
|
151
|
+
item.keyEquivalent.should == 'a'
|
152
|
+
item.action.should == 'action:'.to_sym
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should have a `services_item` method' do
|
156
|
+
item = @subject.services_item
|
157
|
+
item.should.be.kind_of(NSMenuItem)
|
158
|
+
item.keyEquivalent.should == ''
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should have a `services_item` method with options' do
|
162
|
+
item = @subject.services_item(key: 'a', action: 'action:')
|
163
|
+
item.keyEquivalent.should == 'a'
|
164
|
+
item.action.should == 'action:'.to_sym
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should have a `hide_item` method' do
|
168
|
+
item = @subject.hide_item
|
169
|
+
item.should.be.kind_of(NSMenuItem)
|
170
|
+
item.keyEquivalent.should == 'h'
|
171
|
+
item.action.should == 'hide:'.to_sym
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should have a `hide_item` method with options' do
|
175
|
+
item = @subject.hide_item(key: 'a', action: 'action:')
|
176
|
+
item.keyEquivalent.should == 'a'
|
177
|
+
item.action.should == 'action:'.to_sym
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should have a `hide_others_item` method' do
|
181
|
+
item = @subject.hide_others_item
|
182
|
+
item.should.be.kind_of(NSMenuItem)
|
183
|
+
item.keyEquivalent.should == 'h'
|
184
|
+
item.action.should == 'hideOtherApplications:'.to_sym
|
185
|
+
item.keyEquivalentModifierMask.should == NSCommandKeyMask | NSAlternateKeyMask
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should have a `hide_others_item` method with options' do
|
189
|
+
item = @subject.hide_others_item(key: 'a', action: 'action:')
|
190
|
+
item.keyEquivalent.should == 'a'
|
191
|
+
item.action.should == 'action:'.to_sym
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should have a `show_all_item` method' do
|
195
|
+
item = @subject.show_all_item
|
196
|
+
item.should.be.kind_of(NSMenuItem)
|
197
|
+
item.keyEquivalent.should == ''
|
198
|
+
item.action.should == 'unhideAllApplications:'.to_sym
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should have a `show_all_item` method with options' do
|
202
|
+
item = @subject.show_all_item(key: 'a', action: 'action:')
|
203
|
+
item.keyEquivalent.should == 'a'
|
204
|
+
item.action.should == 'action:'.to_sym
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'should have a `quit_item` method' do
|
208
|
+
item = @subject.quit_item
|
209
|
+
item.should.be.kind_of(NSMenuItem)
|
210
|
+
item.keyEquivalent.should == 'q'
|
211
|
+
item.action.should == 'terminate:'.to_sym
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should have a `quit_item` method with options' do
|
215
|
+
item = @subject.quit_item(key: 'a', action: 'action:')
|
216
|
+
item.keyEquivalent.should == 'a'
|
217
|
+
item.action.should == 'action:'.to_sym
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should have a `new_item` method' do
|
221
|
+
item = @subject.new_item
|
222
|
+
item.should.be.kind_of(NSMenuItem)
|
223
|
+
item.keyEquivalent.should == 'n'
|
224
|
+
item.action.should == 'newDocument:'.to_sym
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'should have a `new_item` method with options' do
|
228
|
+
item = @subject.new_item(key: 'a', action: 'action:')
|
229
|
+
item.keyEquivalent.should == 'a'
|
230
|
+
item.action.should == 'action:'.to_sym
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'should have a `open_item` method' do
|
234
|
+
item = @subject.open_item
|
235
|
+
item.should.be.kind_of(NSMenuItem)
|
236
|
+
item.keyEquivalent.should == 'o'
|
237
|
+
item.action.should == 'openDocument:'.to_sym
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'should have a `open_item` method with options' do
|
241
|
+
item = @subject.open_item(key: 'a', action: 'action:')
|
242
|
+
item.keyEquivalent.should == 'a'
|
243
|
+
item.action.should == 'action:'.to_sym
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should have a `close_item` method' do
|
247
|
+
item = @subject.close_item
|
248
|
+
item.should.be.kind_of(NSMenuItem)
|
249
|
+
item.keyEquivalent.should == 'w'
|
250
|
+
item.action.should == 'performClose:'.to_sym
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'should have a `close_item` method with options' do
|
254
|
+
item = @subject.close_item(key: 'a', action: 'action:')
|
255
|
+
item.keyEquivalent.should == 'a'
|
256
|
+
item.action.should == 'action:'.to_sym
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should have a `save_item` method' do
|
260
|
+
item = @subject.save_item
|
261
|
+
item.should.be.kind_of(NSMenuItem)
|
262
|
+
item.keyEquivalent.should == 's'
|
263
|
+
item.action.should == 'saveDocument:'.to_sym
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should have a `save_item` method with options' do
|
267
|
+
item = @subject.save_item(key: 'a', action: 'action:')
|
268
|
+
item.keyEquivalent.should == 'a'
|
269
|
+
item.action.should == 'action:'.to_sym
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'should have a `save_as_item` method' do
|
273
|
+
item = @subject.save_as_item
|
274
|
+
item.should.be.kind_of(NSMenuItem)
|
275
|
+
item.keyEquivalent.should == 'S'
|
276
|
+
item.action.should == 'saveDocumentAs:'.to_sym
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'should have a `save_as_item` method with options' do
|
280
|
+
item = @subject.save_as_item(key: 'a', action: 'action:')
|
281
|
+
item.keyEquivalent.should == 'a'
|
282
|
+
item.action.should == 'action:'.to_sym
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'should have a `revert_to_save_item` method' do
|
286
|
+
item = @subject.revert_to_save_item
|
287
|
+
item.should.be.kind_of(NSMenuItem)
|
288
|
+
item.keyEquivalent.should == ''
|
289
|
+
item.action.should == 'revertDocumentToSaved:'.to_sym
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'should have a `revert_to_save_item` method with options' do
|
293
|
+
item = @subject.revert_to_save_item(key: 'a', action: 'action:')
|
294
|
+
item.keyEquivalent.should == 'a'
|
295
|
+
item.action.should == 'action:'.to_sym
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should have a `page_setup_item` method' do
|
299
|
+
item = @subject.page_setup_item
|
300
|
+
item.should.be.kind_of(NSMenuItem)
|
301
|
+
item.keyEquivalent.should == 'P'
|
302
|
+
item.action.should == 'runPageLayout:'.to_sym
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'should have a `page_setup_item` method with options' do
|
306
|
+
item = @subject.page_setup_item(key: 'a', action: 'action:')
|
307
|
+
item.keyEquivalent.should == 'a'
|
308
|
+
item.action.should == 'action:'.to_sym
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should have a `print_item` method' do
|
312
|
+
item = @subject.print_item
|
313
|
+
item.should.be.kind_of(NSMenuItem)
|
314
|
+
item.keyEquivalent.should == 'p'
|
315
|
+
item.action.should == 'printDocument:'.to_sym
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'should have a `print_item` method with options' do
|
319
|
+
item = @subject.print_item(key: 'a', action: 'action:')
|
320
|
+
item.keyEquivalent.should == 'a'
|
321
|
+
item.action.should == 'action:'.to_sym
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'should have a `minimize_item` method' do
|
325
|
+
item = @subject.minimize_item
|
326
|
+
item.should.be.kind_of(NSMenuItem)
|
327
|
+
item.keyEquivalent.should == 'm'
|
328
|
+
item.action.should == 'performMiniaturize:'.to_sym
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'should have a `minimize_item` method with options' do
|
332
|
+
item = @subject.minimize_item(key: 'a', action: 'action:')
|
333
|
+
item.keyEquivalent.should == 'a'
|
334
|
+
item.action.should == 'action:'.to_sym
|
335
|
+
end
|
336
|
+
|
337
|
+
it 'should have a `zoom_item` method' do
|
338
|
+
item = @subject.zoom_item
|
339
|
+
item.should.be.kind_of(NSMenuItem)
|
340
|
+
item.keyEquivalent.should == ''
|
341
|
+
item.action.should == 'performMiniaturize:'.to_sym
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'should have a `zoom_item` method with options' do
|
345
|
+
item = @subject.zoom_item(key: 'a', action: 'action:')
|
346
|
+
item.keyEquivalent.should == 'a'
|
347
|
+
item.action.should == 'action:'.to_sym
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should have a `bring_all_to_front_item` method' do
|
351
|
+
item = @subject.bring_all_to_front_item
|
352
|
+
item.should.be.kind_of(NSMenuItem)
|
353
|
+
item.keyEquivalent.should == ''
|
354
|
+
item.action.should == 'arrangeInFront:'.to_sym
|
355
|
+
end
|
356
|
+
|
357
|
+
it 'should have a `bring_all_to_front_item` method with options' do
|
358
|
+
item = @subject.bring_all_to_front_item(key: 'a', action: 'action:')
|
359
|
+
item.keyEquivalent.should == 'a'
|
360
|
+
item.action.should == 'action:'.to_sym
|
361
|
+
end
|
362
|
+
|
363
|
+
it 'should have a `help_item` method' do
|
364
|
+
item = @subject.help_item
|
365
|
+
item.should.be.kind_of(NSMenuItem)
|
366
|
+
item.keyEquivalent.should == '?'
|
367
|
+
item.action.should == 'showHelp:'.to_sym
|
368
|
+
end
|
369
|
+
|
370
|
+
it 'should have a `help_item` method with options' do
|
371
|
+
item = @subject.help_item(key: 'a', action: 'action:')
|
372
|
+
item.keyEquivalent.should == 'a'
|
373
|
+
item.action.should == 'action:'.to_sym
|
374
|
+
end
|
375
|
+
|
376
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
describe TestMenu do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@subject = TestMenu.new
|
5
|
+
@menu = @subject.view
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should create a menu' do
|
9
|
+
@menu.should.not == nil
|
10
|
+
@menu.should.be.kind_of(NSMenu)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should return the menu via `menu`' do
|
14
|
+
@subject.menu.should == @menu
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have three items' do
|
18
|
+
@subject.menu.itemArray.length.should == 3
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have a "File" item' do
|
22
|
+
file_item = @subject.menu.itemArray[0]
|
23
|
+
file_item.should.not == nil
|
24
|
+
file_item.should.be.kind_of(NSMenuItem)
|
25
|
+
file_item.title.should == 'File'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have a "File" menu with submenu' do
|
29
|
+
file_item = @subject.menu.itemArray[0]
|
30
|
+
file_menu = file_item.submenu
|
31
|
+
file_menu.itemArray.length.should > 0
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a "File" menu with an "Open" item' do
|
35
|
+
file_item = @subject.menu.itemArray[0]
|
36
|
+
file_menu = file_item.submenu
|
37
|
+
open_menu = file_menu.itemArray[0]
|
38
|
+
open_menu.title.should == 'Open'
|
39
|
+
open_menu.keyEquivalent.should == 'o'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have a "File" menu with an "Close" item' do
|
43
|
+
file_item = @subject.menu.itemArray[0]
|
44
|
+
file_menu = file_item.submenu
|
45
|
+
close_menu = file_menu.itemArray[1]
|
46
|
+
close_menu.title.should == 'Close'
|
47
|
+
close_menu.keyEquivalent.should == 'w'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should have a "File" menu with an "Foo" item' do
|
51
|
+
file_item = @subject.menu.itemArray[0]
|
52
|
+
file_menu = file_item.submenu
|
53
|
+
foo_menu = file_menu.itemArray[2]
|
54
|
+
foo_menu.title.should == 'Foo'
|
55
|
+
@subject.foo.should == foo_menu
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have a "File" menu with an "Bar" item' do
|
59
|
+
file_item = @subject.menu.itemArray[0]
|
60
|
+
file_menu = file_item.submenu
|
61
|
+
bar_menu = file_menu.itemArray[3]
|
62
|
+
bar_menu.title.should == 'Bar'
|
63
|
+
@subject.bar.should == bar_menu.submenu
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have a "Views" item' do
|
67
|
+
views_item = @subject.menu.itemArray[1]
|
68
|
+
views_item.should.not == nil
|
69
|
+
views_item.should.be.kind_of(NSMenuItem)
|
70
|
+
views_item.title.should == 'Views'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have a "Views" menu with submenu' do
|
74
|
+
views_item = @subject.menu.itemArray[1]
|
75
|
+
views_menu = views_item.submenu
|
76
|
+
views_menu.itemArray.length.should > 0
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should have a "Views" menu with a "Windows" submenu' do
|
80
|
+
views_item = @subject.menu.itemArray[1]
|
81
|
+
views_menu = views_item.submenu
|
82
|
+
open_menu = views_menu.itemArray[0]
|
83
|
+
open_menu.should.not == nil
|
84
|
+
open_menu.title.should == 'Windows'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should have a "Views" menu with a "Windows" submenu with items' do
|
88
|
+
views_item = @subject.menu.itemArray[1]
|
89
|
+
views_menu = views_item.submenu
|
90
|
+
open_menu = views_menu.itemArray[0]
|
91
|
+
open_menu.submenu.should.not == nil
|
92
|
+
open_menu.submenu.should.be.kind_of(NSMenu)
|
93
|
+
open_menu.submenu.itemArray.length.should > 0
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should have a "Views" menu with a "Windows" submenu with "First" item' do
|
97
|
+
views_item = @subject.menu.itemArray[1]
|
98
|
+
views_menu = views_item.submenu
|
99
|
+
open_menu = views_menu.itemArray[0]
|
100
|
+
first_item = open_menu.submenu.itemArray[0]
|
101
|
+
first_item.title.should == 'First'
|
102
|
+
first_item.keyEquivalent.should == '1'
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should have a "Things" item' do
|
106
|
+
things_item = @subject.menu.itemArray[2]
|
107
|
+
things_item.should.not == nil
|
108
|
+
things_item.should.be.kind_of(NSMenuItem)
|
109
|
+
things_item.title.should == 'Things'
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should have a "Things" menu with submenu' do
|
113
|
+
things_item = @subject.menu.itemArray[2]
|
114
|
+
things_menu = things_item.submenu
|
115
|
+
things_menu.itemArray.length.should > 0
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should have a "Things" menu with a "Thing 1" submenu' do
|
119
|
+
things_item = @subject.menu.itemArray[2]
|
120
|
+
things_menu = things_item.submenu
|
121
|
+
open_menu = things_menu.itemArray[0]
|
122
|
+
open_menu.title.should == 'Thing 1'
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should have a "Things" menu with a "Thing 2" submenu' do
|
126
|
+
things_item = @subject.menu.itemArray[2]
|
127
|
+
things_menu = things_item.submenu
|
128
|
+
open_menu = things_menu.itemArray[1]
|
129
|
+
open_menu.title.should == 'Thing 2'
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should have a "Things" menu with a "Menu" submenu' do
|
133
|
+
things_item = @subject.menu.itemArray[2]
|
134
|
+
things_menu = things_item.submenu
|
135
|
+
menu_menu = things_menu.itemArray[2]
|
136
|
+
menu_menu.should.not == nil
|
137
|
+
menu_menu.title.should == 'Menu'
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should have a "Things" menu with a "Menu" submenu with items' do
|
141
|
+
things_item = @subject.menu.itemArray[2]
|
142
|
+
things_menu = things_item.submenu
|
143
|
+
menu_menu = things_menu.itemArray[2]
|
144
|
+
menu_menu.submenu.should.not == nil
|
145
|
+
menu_menu.submenu.should.be.kind_of(NSMenu)
|
146
|
+
menu_menu.submenu.itemArray.length.should > 0
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should have a "Things" menu with a "Menu" submenu with "Submenu" item' do
|
150
|
+
things_item = @subject.menu.itemArray[2]
|
151
|
+
things_menu = things_item.submenu
|
152
|
+
menu_menu = things_menu.itemArray[2]
|
153
|
+
submenu_item = menu_menu.submenu.itemArray[0]
|
154
|
+
submenu_item.title.should == 'Submenu'
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|