Module: MiniTest::Assertions

Defined in:
lib/minitest/macruby.rb

Instance Method Summary collapse

Instance Method Details

#assert_ui_action(obj, target, action, key = nil) ⇒ Object



41
42
43
44
45
46
# File 'lib/minitest/macruby.rb', line 41

def assert_ui_action obj, target, action, key = nil
  refute_nil obj, action
  assert_equal target,        obj.target
  assert_equal action.to_sym, obj.action
  assert_equal key,           obj.keyEquivalent if key
end

#assert_ui_binding(item, binding_name, target, path) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/minitest/macruby.rb', line 48

def assert_ui_binding item, binding_name, target, path
  refute_nil item
  refute_nil target
  binding = item.infoForBinding binding_name.to_s
  refute_nil binding
  assert_equal path, binding["NSObservedKeyPath"]
  assert_equal target, binding["NSObservedObject"]
end

#assert_ui_menu(menu, *items) ⇒ Object



30
31
32
33
34
# File 'lib/minitest/macruby.rb', line 30

def assert_ui_menu menu, *items
  item_titles = find_ui_menu_items(menu).map { |item| item.title }

  assert_equal items, item_titles
end

#find_ui_menu(*path) ⇒ Object



19
20
21
22
# File 'lib/minitest/macruby.rb', line 19

def find_ui_menu(*path)
  app  = NSApplication.sharedApplication
  menu = path.inject(app.mainMenu) { |m, n| m.itemWithTitle(n).submenu }
end

#find_ui_menu_item(*path) ⇒ Object



36
37
38
39
# File 'lib/minitest/macruby.rb', line 36

def find_ui_menu_item(*path)
  item_name = path.pop
  find_ui_menu(path).itemWithTitle item_name
end

#find_ui_menu_items(menu) ⇒ Object



24
25
26
27
28
# File 'lib/minitest/macruby.rb', line 24

def find_ui_menu_items menu
  menu = find_ui_menu menu

  menu.itemArray
end