-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_replace_point.rb
More file actions
49 lines (35 loc) · 1.27 KB
/
test_replace_point.rb
File metadata and controls
49 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require 'ui'
class ReplacePointTest < Test::Unit::TestCase
include UI::Builder
def test_replace
# FIXME parent is not defined inside replace_point, so it breaks (oh noes! :-()
# dialog = main_dialog {
# vbox {
# label "This is fixed", :id => :lbl1
# replace_point(:id => :point) {
# label"Original content", :id => :lbl2
# }
# }
# }
dialog = UI::Builder.create_main_dialog
vbox = UI::Builder.create_vbox dialog
fixed_label = UI::Builder.create_label vbox, "This is fixed" #, :id => :lbl1
fixed_label.id = :lbl1
replace_point = UI::Builder.create_replace_point vbox #, :id => :point
replace_point.id = :point
label = UI::Builder.create_label replace_point, "Original content" #, :id => :lbl2
label.id = :lbl2
assert_raise(RuntimeError, "Only works with replace points") do
dialog.replace(:lbl1) do
label "New content"
end
end
assert_equal("Original content", dialog.find(:lbl2)[:Value])
dialog.replace(:point) do
new_label = UI::Builder.create_label replace_point, "New content"
new_label.id = :lbl2
end
assert_equal("New content", dialog.find(:lbl2)[:Value])
end
end