/
builder_spec.rb
61 lines (53 loc) · 1.69 KB
/
builder_spec.rb
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
50
51
52
53
54
55
56
57
58
59
60
require "spec_helper"
describe "Redcar::Menu::Builder DSL" do
it "creates a menu" do
builder = Redcar::Menu::Builder.new {}
builder.menu.should be_an_instance_of(Redcar::Menu)
builder.menu.length.should == 0
end
it "adds entries to the menu" do
builder = Redcar::Menu::Builder.new do
item "New", :OpenNewEditTabCommand
end
builder.menu.length.should == 1
item = builder.menu.entries.first
item.text.should == "New"
item.command.should == :OpenNewEditTabCommand
end
it "adds separators to the menu" do
builder = Redcar::Menu::Builder.new do
separator
end
builder.menu.length.should == 1
item = builder.menu.entries.first
item.should be_an_instance_of(Redcar::Menu::Item::Separator)
end
it "adds submenus to the menu" do
builder = Redcar::Menu::Builder.new do
sub_menu "Export" do
item "PDF", :PDFCommand
end
item "Exit", :ExitCommand
end
builder.menu.length.should == 2
sub_menu = builder.menu.entries.first
sub_menu.should be_an_instance_of(Redcar::Menu)
sub_menu.text.should == "Export"
sub_menu.length.should == 1
sub_menu.entries.first.text.should == "PDF"
top_item = builder.menu.entries.last
top_item.text.should == "Exit"
end
it "adds lazy submenus to the menu" do
builder = Redcar::Menu::Builder.new do
lazy_sub_menu "Export" do
item "PDF", :PDFCommand
end
end
builder.menu.length.should == 1
lazy_sub_menu = builder.menu.entries.first
lazy_sub_menu.should be_an_instance_of(Redcar::Menu::LazyMenu)
lazy_sub_menu.entries.length.should == 1
lazy_sub_menu.entries.first.text.should == "PDF"
end
end