evegem 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +14 -0
- data/Gemfile +5 -0
- data/Rakefile +5 -0
- data/autotest/discover.rb +2 -0
- data/bin/eve +18 -0
- data/config.ru +2 -0
- data/config/database.yml.example +16 -0
- data/config/reset_db.rb +10 -0
- data/eve.gemspec +39 -0
- data/lib/eve/application.rb +465 -0
- data/lib/eve/ci.rake +68 -0
- data/lib/eve/event_server.rb +67 -0
- data/lib/eve/file_notifier_server.rb +77 -0
- data/lib/eve/io.rb +25 -0
- data/lib/eve/layout.rb +22 -0
- data/lib/eve/message.rb +181 -0
- data/lib/eve/messenger.rb +138 -0
- data/lib/eve/registry.rb +35 -0
- data/lib/eve/version.rb +3 -0
- data/lib/eve/web_server.rb +22 -0
- data/lib/evegem.rb +23 -0
- data/lib/registry/base_registry.rb +60 -0
- data/lib/registry/charlie_test.rb +18 -0
- data/lib/registry/echo_test.rb +22 -0
- data/lib/registry/empty_registry.rb +11 -0
- data/spec/application_spec.rb +738 -0
- data/spec/base_registry_spec.rb +134 -0
- data/spec/event_server_spec.rb +73 -0
- data/spec/file_notifier_server_spec.rb +89 -0
- data/spec/files/niner_registry.rb +23 -0
- data/spec/layout_spec.rb +28 -0
- data/spec/message_spec.rb +246 -0
- data/spec/messenger_spec.rb +399 -0
- data/spec/spec_helper.rb +35 -0
- metadata +276 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Eve
|
4
|
+
|
5
|
+
describe "BaseRegistry" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
`mkdir -p ./application_test`
|
9
|
+
`mkdir -p ./application_test2`
|
10
|
+
@redis = Utest::InmemoryRedis.new
|
11
|
+
@app = Application.new(:display => :string, :redis => @redis)
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
`rm -rf ./application_test`
|
16
|
+
`rm -rf ./application_test2`
|
17
|
+
`rm -f deleteme.txt deleteme2.txt`
|
18
|
+
`rm -rf ./eve.cmd`
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#cmd" do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@app.cmd("appid")
|
25
|
+
@app.cmd("register add Eve::BaseRegistry")
|
26
|
+
@app.reset
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "help" do
|
30
|
+
|
31
|
+
it "should know about the commands" do
|
32
|
+
@app.cmd("help Eve::BaseRegistry")[:data].should == {
|
33
|
+
"export" => [],
|
34
|
+
"import" => [],
|
35
|
+
"sleep" => [],
|
36
|
+
"ruby" => [],
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "export" do
|
43
|
+
|
44
|
+
it "should handle no file" do
|
45
|
+
result = @app.cmd("export")
|
46
|
+
result[:data].should == "./eve.cmd"
|
47
|
+
@app.history.should == ["Exported all commands to ./eve.cmd -- reload using 'import ./eve.cmd'\n"]
|
48
|
+
IO.read("./eve.cmd").should == ""
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should store explicit cmds" do
|
52
|
+
@app.cmd("version",true,false)
|
53
|
+
@app.cmd("source --show-password",true,true)
|
54
|
+
@app.cmd("ls",true,true)
|
55
|
+
@app.cmd("target",true)
|
56
|
+
|
57
|
+
result = @app.cmd("export")
|
58
|
+
result[:data].should == "./eve.cmd"
|
59
|
+
IO.read("./eve.cmd").should == "source --show-password\nls"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should use file if provided" do
|
63
|
+
@app.cmd("version",true,true)
|
64
|
+
@app.cmd("source --show-password",true,true)
|
65
|
+
|
66
|
+
result = @app.cmd("export ./application_test/myeve.cmd")
|
67
|
+
result[:data].should == "./application_test/myeve.cmd"
|
68
|
+
IO.read("./application_test/myeve.cmd").should == "version\nsource --show-password"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "import" do
|
74
|
+
|
75
|
+
it "should handle no explicit file provided" do
|
76
|
+
IO.write("./eve.cmd","version")
|
77
|
+
result = @app.cmd("import")
|
78
|
+
result[:data].should == "./eve.cmd"
|
79
|
+
@app.history.should == ["Importing comamnds from ./eve.cmd\n", "eve #{$$}, version 0.1.2\n", "Finished importing 1 command (./eve.cmd)\n"]
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should ignore empty commands" do
|
83
|
+
IO.write("./eve.cmd","\n\n\n #about to call version\nversion")
|
84
|
+
result = @app.cmd("import")
|
85
|
+
result[:data].should == "./eve.cmd"
|
86
|
+
@app.history.should == ["Importing comamnds from ./eve.cmd\n", "eve #{$$}, version 0.1.2\n", "Finished importing 1 command (./eve.cmd)\n"]
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should not track the import, but rather the internal commands" do
|
90
|
+
IO.write("./eve.cmd","version")
|
91
|
+
@app.cmd("import")
|
92
|
+
|
93
|
+
@app.cmds.should == ["version"]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should use file if provided" do
|
97
|
+
IO.write("./application_test/myeve.cmd","version")
|
98
|
+
result = @app.cmd("import ./application_test/myeve.cmd")
|
99
|
+
result[:data].should == "./application_test/myeve.cmd"
|
100
|
+
@app.history.should == ["Importing comamnds from ./application_test/myeve.cmd\n", "eve #{$$}, version 0.1.2\n", "Finished importing 1 command (./application_test/myeve.cmd)\n"]
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "ruby" do
|
106
|
+
|
107
|
+
it "should run arbitrary ruby" do
|
108
|
+
@app.cmd("ruby $$").should == { :data => $$, :status => :continue, :track_cmd => true }
|
109
|
+
@app.history.should == [ "$$: #{$$}\n" ]
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "sleep" do
|
115
|
+
|
116
|
+
it "should sleep for a certain period of time" do
|
117
|
+
Kernel.should_receive(:sleep).with(300)
|
118
|
+
@app.cmd("sleep 5minutes").should == { :data => 300, :status => :continue, :track_cmd => true }
|
119
|
+
@app.history.should == [ "Sleeping for 5 minutes (300 seconds)\n" ]
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should only show seconds if that's the output" do
|
123
|
+
Kernel.should_receive(:sleep).with(10)
|
124
|
+
@app.cmd("sleep 10seconds").should == { :data => 10, :status => :continue, :track_cmd => true }
|
125
|
+
@app.history.should == [ "Sleeping for 10 seconds\n" ]
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Eve
|
4
|
+
|
5
|
+
describe EventServer do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@conn = MockConnection.new
|
9
|
+
@app = Application.new(:display => :string, :redis => Utest::InmemoryRedis.new)
|
10
|
+
@conn.app = @app
|
11
|
+
@server = EventServer.new(@conn, { :appid => "mg" })
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#initialize" do
|
15
|
+
|
16
|
+
it "should accept an connection and appid" do
|
17
|
+
@server = EventServer.new(@conn, { :appid => "mg" })
|
18
|
+
@server.connection.should == @conn
|
19
|
+
@server.appid.should == "mg"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#handle_args" do
|
25
|
+
|
26
|
+
it "should return default data" do
|
27
|
+
EventServer.handle_args([]).should == { :server => "0.0.0.0", :port => "4848", :appid => "myeve" }
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should extract from args" do
|
31
|
+
EventServer.handle_args(["--server","1.1.1.1","--port","1234","--id","youreve"]).should == { :server => "1.1.1.1", :port => "1234", :appid => "youreve" }
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#app" do
|
37
|
+
|
38
|
+
it "should create an application if nil" do
|
39
|
+
@conn.app = nil
|
40
|
+
@server.app.should_not == nil
|
41
|
+
@server.app.should == @server.connection.app
|
42
|
+
@server.connection.app.console.display.should == { :event_machine => @conn }
|
43
|
+
@server.connection.app.system_calls.display.should == { :filename => "./eve_server_calls.log" }
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#post_init" do
|
49
|
+
|
50
|
+
it "should create an application" do
|
51
|
+
@server.post_init
|
52
|
+
@server.connection.app.history.should == [ "Appid: mg\n" ]
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#receive_data" do
|
58
|
+
|
59
|
+
it "should run that command" do
|
60
|
+
@server.receive_data("version")
|
61
|
+
@app.history.should == [ "eve, version 0.1.2\n" ]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should exit if exited" do
|
65
|
+
@conn.should_receive(:close_connection)
|
66
|
+
@server.receive_data("exit")
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Eve
|
4
|
+
|
5
|
+
describe FileNotifierServer do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@conn = MockConnection.new
|
9
|
+
@app = Application.new(:display => :string, :redis => Utest::InmemoryRedis.new)
|
10
|
+
@conn.app = @app
|
11
|
+
@server = FileNotifierServer.new(@conn, { :appid => "mg" })
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#initialize" do
|
15
|
+
|
16
|
+
it "should accept an connection and data" do
|
17
|
+
@server = FileNotifierServer.new(@conn, { :server => "1.1.1.1", :port => "1234", :source => "/a/b/c", :appid => "mg", :inits => ["register add Eve::BaseRegistry"], :callbacks => ["source fetch /a/b/c"] })
|
18
|
+
@server.connection.should == @conn
|
19
|
+
@server.server.should == "1.1.1.1"
|
20
|
+
@server.port.should == "1234"
|
21
|
+
@server.source.should == "/a/b/c"
|
22
|
+
@server.source.to_s.should == "/a/b/c"
|
23
|
+
@server.appid.should == "mg"
|
24
|
+
@server.callbacks.should == ["source fetch /a/b/c"]
|
25
|
+
@server.inits.should == ["register add Eve::BaseRegistry"]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#handle_args" do
|
31
|
+
|
32
|
+
it "should return default data" do
|
33
|
+
FileNotifierServer.handle_args([]).should == { :server => nil, :port => nil, :source => nil, :appid => nil, :callbacks => [], :inits => [] }
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should extract from args" do
|
37
|
+
FileNotifierServer.handle_args(["--server","1.1.1.1","--port","1234","--id","youreve","--source","/tmp", "--callback", "do", "something", "--callback", "and", "this", "--init", "do", "a", "--init", "do", "b"]).should == { :server => "1.1.1.1", :port => "1234", :source => "/tmp", :appid => "youreve", :inits => [ "do a", "do b" ], :callbacks => ["do something", "and this"]}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#app" do
|
43
|
+
|
44
|
+
before(:each) do
|
45
|
+
@server.connection.app = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be local if appid set" do
|
49
|
+
@server = FileNotifierServer.new(@conn, { :appid => "mg" })
|
50
|
+
@server.app.console.display.should == :stdio
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should connect to event server if provided" do
|
54
|
+
@server = FileNotifierServer.new(@conn, { :server => "1.1.1.1", :port => "4848" })
|
55
|
+
@server.app.console.display.should == :stdio
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#post_init" do
|
61
|
+
|
62
|
+
it "should be local if appid set" do
|
63
|
+
@app.should_receive(:cmd).with("appid mg")
|
64
|
+
@server = FileNotifierServer.new(@conn, { :appid => "mg", :source => "/tmp" })
|
65
|
+
@server.post_init
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should connect to event server if provided" do
|
69
|
+
@app.should_receive(:cmd).with("event 1.1.1.1:4848")
|
70
|
+
@server = FileNotifierServer.new(@conn, { :server => "1.1.1.1", :port => "4848", :source => "/tmp" })
|
71
|
+
@server.post_init
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#file_modified" do
|
77
|
+
|
78
|
+
it "should run that command" do
|
79
|
+
@app.should_receive(:cmd).with("source fetch /a/b/c")
|
80
|
+
@app.should_receive(:cmd).with("do something self")
|
81
|
+
@server = FileNotifierServer.new(@conn, { :source => "/a/b/c", :callbacks => [ "source fetch /a/b/c", "do something self" ] })
|
82
|
+
@server.file_modified
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sample
|
2
|
+
|
3
|
+
class NinerRegistry < Eve::Registry
|
4
|
+
|
5
|
+
def self.available
|
6
|
+
{ "niner-test" => [], "version" => [] }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.call_niner_test(app,result,data,display_messages)
|
10
|
+
result[:data] = data
|
11
|
+
app.console.print("NINER: #{result[:data]}\n") if display_messages
|
12
|
+
result
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.call_version(app,result,data,display_messages)
|
16
|
+
result[:data] = "4848"
|
17
|
+
app.console.print("version 4848\n") if display_messages
|
18
|
+
result
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/layout_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Eve
|
2
|
+
|
3
|
+
describe Layout do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@layout = Layout.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "add_column" do
|
10
|
+
|
11
|
+
it "should accept a type, filter and order" do
|
12
|
+
expected = { :column_type => :id, :filter => "[a-zA-Z].*[0-9]", :order => 9 }
|
13
|
+
@layout.add_column("ID;[a-zA-Z].*[0-9];9").should == expected
|
14
|
+
@layout.columns.should == [ expected ]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return nil if invalid input" do
|
18
|
+
@layout.add_column(nil).should == nil
|
19
|
+
@layout.columns.should == [ ]
|
20
|
+
@layout.add_column("a").should == nil
|
21
|
+
@layout.columns.should == [ ]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Eve
|
4
|
+
|
5
|
+
describe Message do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@app = Application.new(:display => :string, :redis => Utest::InmemoryRedis.new)
|
9
|
+
@console = @app.console
|
10
|
+
@system_calls = @app.system_calls
|
11
|
+
@msg = @app.message
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "print_version" do
|
15
|
+
|
16
|
+
it "should default" do
|
17
|
+
@msg.print_version(123)
|
18
|
+
@console.history.should == [ "eve 123 (#{$$}), version 0.1.2\n" ]
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should support nil appids" do
|
22
|
+
@msg.print_version(nil)
|
23
|
+
@console.history.should == [ "eve, version 0.1.2\n" ]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should ignore process id if same as name" do
|
27
|
+
@msg.print_version($$)
|
28
|
+
@console.history.should == [ "eve #{$$}, version 0.1.2\n" ]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "print_registry_path" do
|
34
|
+
|
35
|
+
it "should handle none" do
|
36
|
+
@msg.print_registry_path([])
|
37
|
+
@console.history.should == ["No paths have been provided.\n"]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should handle none" do
|
41
|
+
@msg.print_registry_path(["a","b"])
|
42
|
+
@console.history.should == ["The following paths have been set:\n -- a\n -- b\n"]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "print_error" do
|
48
|
+
|
49
|
+
it "should track both messages" do
|
50
|
+
begin
|
51
|
+
a.cannot_do_that
|
52
|
+
rescue Exception => ex
|
53
|
+
@msg.print_error("a",ex)
|
54
|
+
end
|
55
|
+
@console.history[0].should == "a\n"
|
56
|
+
@console.history[1][0..39].should == " undefined local variable or method `a'"
|
57
|
+
@console.history[2].size.should > 100
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "print_system_call" do
|
63
|
+
|
64
|
+
it "should track the calling" do
|
65
|
+
@msg.print_system_call("abc")
|
66
|
+
@system_calls.history.should == [ "CALLING: abc\n" ]
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "print_*" do
|
72
|
+
|
73
|
+
it "print_exit" do
|
74
|
+
@msg.print_exit
|
75
|
+
@console.history.should == [ "bye\n" ]
|
76
|
+
end
|
77
|
+
|
78
|
+
it "print_unknown_cmd" do
|
79
|
+
@msg.print_unknown_cmd("abc")
|
80
|
+
@console.history.should == [ "UNKNOWN CMD: abc\n" ]
|
81
|
+
end
|
82
|
+
|
83
|
+
it "print_process_id" do
|
84
|
+
@msg.print_process_id("abc123")
|
85
|
+
@console.history.should == [ "Process Id: abc123\n" ]
|
86
|
+
end
|
87
|
+
|
88
|
+
it "print_ruby_call" do
|
89
|
+
@msg.print_ruby_call("a","b")
|
90
|
+
@console.history.should == [ "a: b\n" ]
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "print_sleep" do
|
94
|
+
|
95
|
+
it "should show minutes and seconds" do
|
96
|
+
@msg.print_sleep(600)
|
97
|
+
@console.history.should == [ "Sleeping for 10 minutes (600 seconds)\n" ]
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should only show seconds if < 1 minute" do
|
101
|
+
@msg.print_sleep(10)
|
102
|
+
@console.history.should == [ "Sleeping for 10 seconds\n" ]
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
it "print_shell_mode" do
|
109
|
+
@msg.print_shell_mode
|
110
|
+
@console.history.should == [ "Entering shell mode, to exit this mode, type 'poll'\n" ]
|
111
|
+
end
|
112
|
+
|
113
|
+
it "print_event_mode" do
|
114
|
+
@msg.print_event_mode("0.0.0.0:4848")
|
115
|
+
@console.history.should == [ "Messages will be routed to 0.0.0.0:4848\n" ]
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "print_poll_details" do
|
119
|
+
|
120
|
+
it "should say it has nothing to do" do
|
121
|
+
@msg.print_poll_details(1800,[])
|
122
|
+
@console.history.should == [ "Poll will check every 30 minutes (1800 seconds), but it has nothing to run.\n" ]
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should say it has something to do" do
|
126
|
+
@msg.print_poll_details(1800,["watch x","watch y"])
|
127
|
+
@console.history.should == [ "Poll will check every 30 minutes (1800 seconds), and send the following events:\n - watch x\n - watch y\n" ]
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "print_poll_mode" do
|
133
|
+
|
134
|
+
it "should show minutes and seconds" do
|
135
|
+
@msg.print_poll_mode("abc123", 600)
|
136
|
+
@console.history.should == [ "Entering poll mode with checks every 10 minutes (600 seconds), to exit this mode, run 'eve --interrupt abc123' from another terminal session\n" ]
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should only show seconds if < 1 minute" do
|
140
|
+
@msg.print_poll_mode("abc123", 10)
|
141
|
+
@console.history.should == [ "Entering poll mode with checks every 10 seconds, to exit this mode, run 'eve --interrupt abc123' from another terminal session\n" ]
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
it "print_app_interrupted" do
|
147
|
+
@msg.print_app_interrupted("abc123")
|
148
|
+
@console.history.should == [ "Interrupted eve abc123, should now be in shell mode\n" ]
|
149
|
+
end
|
150
|
+
|
151
|
+
it "print_unknown_handler" do
|
152
|
+
@msg.print_unknown_handler("Blah")
|
153
|
+
@console.history.should == [ "Unknown handler Blah\n" ]
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "print_help" do
|
157
|
+
|
158
|
+
it "default" do
|
159
|
+
@msg.print_help({ "a" => ["list","delete"], "b" => [] })
|
160
|
+
@console.history.should == [ "Available commands are:\n a [ list | delete ]\n b\n" ]
|
161
|
+
end
|
162
|
+
|
163
|
+
it "empty filter" do
|
164
|
+
@msg.print_help({ "a" => ["list","delete"], "b" => [] },"")
|
165
|
+
@console.history.should == [ "Available commands are:\n a [ list | delete ]\n b\n" ]
|
166
|
+
end
|
167
|
+
|
168
|
+
it "filter" do
|
169
|
+
@msg.print_help({ "a" => ["list","delete"], "b" => [] },"Blah")
|
170
|
+
@console.history.should == [ "Available commands (Blah) are:\n a [ list | delete ]\n b\n" ]
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
it "print_exported_commands" do
|
177
|
+
@msg.print_exported_commands("./myeve.cmd")
|
178
|
+
@console.history.should == ["Exported all commands to ./myeve.cmd -- reload using 'import ./myeve.cmd'\n"]
|
179
|
+
end
|
180
|
+
|
181
|
+
it "print_importing_commands" do
|
182
|
+
@msg.print_importing_commands("./myeve.cmd")
|
183
|
+
@console.history.should == ["Importing comamnds from ./myeve.cmd\n"]
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "print_importing_complete" do
|
187
|
+
|
188
|
+
it "none" do
|
189
|
+
@msg.print_importing_complete("./myeve.cmd",0)
|
190
|
+
@console.history.should == ["No commands found!\n"]
|
191
|
+
end
|
192
|
+
|
193
|
+
it "one" do
|
194
|
+
@msg.print_importing_complete("./myeve.cmd",1)
|
195
|
+
@console.history.should == ["Finished importing 1 command (./myeve.cmd)\n"]
|
196
|
+
end
|
197
|
+
|
198
|
+
it "some" do
|
199
|
+
@msg.print_importing_complete("./myeve.cmd",2)
|
200
|
+
@console.history.should == ["Finished importing 2 commands (./myeve.cmd)\n"]
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
it "print_cmd_error" do
|
206
|
+
@msg.print_cmd_error("a 1 2 3")
|
207
|
+
@console.history.should == [ "An error occurred for 'a 1 2 3'\n" ]
|
208
|
+
end
|
209
|
+
|
210
|
+
it "print_server_init" do
|
211
|
+
@msg.print_server_init
|
212
|
+
@console.history.should == [ "Connection Established\n" ]
|
213
|
+
end
|
214
|
+
|
215
|
+
it "print_appid" do
|
216
|
+
@msg.print_appid(123)
|
217
|
+
@console.history.should == [ "Appid: 123\n" ]
|
218
|
+
end
|
219
|
+
|
220
|
+
it "print_registry_reloaded" do
|
221
|
+
@msg.print_registry_reloaded
|
222
|
+
@console.history.should == [ "Registry reloaded.\n" ]
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
describe "print_nothing_registered" do
|
228
|
+
|
229
|
+
it "should handle none" do
|
230
|
+
@msg.print_registry({})
|
231
|
+
@console.history.should == [ "Nothing registered.\n" ]
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should handle some" do
|
235
|
+
@msg.print_registry({ "CharlieTest" => ["x"], "Sample::EchoTest" => ["y"] })
|
236
|
+
@app.history.should == [ "The following has been registered:\n - CharlieTest (x)\n - Sample::EchoTest (y)\n" ]
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
|