yggdrasil 0.0.7 → 0.0.8

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/spec/log_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "log" do
3
+ describe Yggdrasil, 'log' do
4
4
  it '-------- log' do
5
5
  puts '-------- log'
6
6
  prepare_environment
@@ -36,7 +36,7 @@ EOS
36
36
  it 'should show log (relative path)' do
37
37
  puts '---- should show log (relative path)'
38
38
  out = catch_out do
39
- FileUtils.cd "/tmp" do
39
+ FileUtils.cd '/tmp' do
40
40
  Yggdrasil.command %w{log yggdrasil-test}+
41
41
  %w{--username hoge --password foo}
42
42
  end
@@ -66,7 +66,7 @@ EOS
66
66
  it 'should show log (no path)' do
67
67
  puts '---- should show log (no path)'
68
68
  out = catch_out do
69
- FileUtils.cd "/tmp/yggdrasil-test" do
69
+ FileUtils.cd '/tmp/yggdrasil-test' do
70
70
  Yggdrasil.command %w{log} +
71
71
  %w{--username hoge --password foo}
72
72
  end
data/spec/revert_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe Yggdrasil, "revert" do
3
+ describe Yggdrasil, 'revert' do
4
4
  it '-------- revert' do
5
5
  puts '-------- revert'
6
6
  prepare_environment
@@ -12,11 +12,11 @@ describe Yggdrasil, "revert" do
12
12
  puts '---- should commit added files'
13
13
  `echo hoge > /tmp/yggdrasil-test/AA`
14
14
  `echo foo > /tmp/yggdrasil-test/BB`
15
- FileUtils.cd "/tmp/yggdrasil-test" do
15
+ FileUtils.cd '/tmp/yggdrasil-test' do
16
16
  puts '-- add'
17
17
  Yggdrasil.command %w{add AA /tmp/yggdrasil-test/BB}
18
18
 
19
- puts "-- revert"
19
+ puts '-- revert'
20
20
  Yggdrasil.command %w{revert --username hoge --password foo},
21
21
  "0\nY\n"
22
22
  end
@@ -27,15 +27,15 @@ describe Yggdrasil, "revert" do
27
27
  %w{--username hoge --password foo}
28
28
  end
29
29
  puts out
30
- out.should == ""
30
+ out.should == ''
31
31
  end
32
32
 
33
33
  it 'should revert modified file' do
34
- puts "---- should revert modified file"
35
- puts "-- modify"
34
+ puts '---- should revert modified file'
35
+ puts '-- modify'
36
36
  `echo hoge >> /tmp/yggdrasil-test/A`
37
37
 
38
- puts "-- revert"
38
+ puts '-- revert'
39
39
  Yggdrasil.command %w{revert / --username hoge --password foo},
40
40
  "0\nY\n"
41
41
 
@@ -45,11 +45,11 @@ describe Yggdrasil, "revert" do
45
45
  %w{--username hoge --password foo}
46
46
  end
47
47
  puts out
48
- out.should == ""
48
+ out.should == ''
49
49
  end
50
50
 
51
51
  it 'should accept password interactive' do
52
- puts "---- should accept password interactive"
52
+ puts '---- should accept password interactive'
53
53
  `echo A >> /tmp/yggdrasil-test/A`
54
54
 
55
55
  Yggdrasil.command %w{revert /tmp/yggdrasil-test/A --username hoge},
@@ -61,11 +61,11 @@ describe Yggdrasil, "revert" do
61
61
  %w{--username hoge --password foo}
62
62
  end
63
63
  puts out
64
- out.should == ""
64
+ out.should == ''
65
65
  end
66
66
 
67
67
  it 'should revert specified file only' do
68
- puts "---- should revert specified file only"
68
+ puts '---- should revert specified file only'
69
69
  `echo A >> /tmp/yggdrasil-test/A`
70
70
  `echo B >> /tmp/yggdrasil-test/B`
71
71
 
@@ -84,7 +84,7 @@ describe Yggdrasil, "revert" do
84
84
  end
85
85
 
86
86
  it 'should not revert deleted file' do
87
- puts "---- should not revert deleted file"
87
+ puts '---- should not revert deleted file'
88
88
  `rm -f /tmp/yggdrasil-test/A`
89
89
 
90
90
  Yggdrasil.command %w{revert /} +
@@ -99,11 +99,11 @@ describe Yggdrasil, "revert" do
99
99
  out.chomp!
100
100
  puts out
101
101
  out.gsub!(%r{\s+},' ')
102
- out.should == "D 3 tmp/yggdrasil-test/A"
102
+ out.should == 'D 3 tmp/yggdrasil-test/A'
103
103
  end
104
104
 
105
105
  it 'should revert all files at once' do
106
- puts "---- should revert all files at once"
106
+ puts '---- should revert all files at once'
107
107
 
108
108
  `echo HOGE >> /tmp/yggdrasil-test/A`
109
109
  `rm -f /tmp/yggdrasil-test/B`
@@ -121,6 +121,6 @@ describe Yggdrasil, "revert" do
121
121
  %w{--username hoge --password foo}
122
122
  end
123
123
  puts out
124
- out.should == ""
124
+ out.should == ''
125
125
  end
126
126
  end
@@ -0,0 +1,142 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'yggdrasil_server'
3
+
4
+ describe YggdrasilServer, 'help (server)' do
5
+ puts '-------- help (server)'
6
+
7
+ show_subcommands = <<"EOS"
8
+ usage: #{File.basename($0)} <subcommand> [options] [args]
9
+ Yggdrasil version #{Yggdrasil::VERSION}
10
+ Type '#{File.basename($0)} help <subcommand>' for help on a specific subcommand.
11
+
12
+ Available subcommands:
13
+ daemon
14
+ debug
15
+ help (?, h)
16
+ init
17
+ results
18
+ version
19
+
20
+ Yggdrasil server is a TCP server
21
+ to receive/record the yggdrasil check result of all managed servers.
22
+
23
+ At first, you should type '#{File.basename($0)} init' to create config file.
24
+
25
+ EOS
26
+
27
+ it 'should show subcommands on no subcommands (server)' do
28
+ puts '---- should show subcommands on no subcommands (server)'
29
+ out = catch_out{YggdrasilServer.command []}
30
+ out.should == show_subcommands
31
+ end
32
+
33
+ it 'should show subcommands on "help" (server)' do
34
+ puts '---- should show subcommands on "help" (server)'
35
+ out = catch_out{YggdrasilServer.command %w{help}}
36
+ out.should == show_subcommands
37
+ end
38
+
39
+ it 'should show subcommands on "h" (server)' do
40
+ puts '---- should show subcommands on "h" (server)'
41
+ out = catch_out{YggdrasilServer.command %w{h}}
42
+ out.should == show_subcommands
43
+ end
44
+
45
+ it 'should show subcommands on "?" (server)' do
46
+ puts '---- should show subcommands on "?" (server)'
47
+ out = catch_out{YggdrasilServer.command %w{?}}
48
+ out.should == show_subcommands
49
+ end
50
+
51
+ it 'should be unknown subcommand on "hoge" (server)' do
52
+ puts '---- should be unknown subcommand on "hoge" (server)'
53
+ err = catch_err do
54
+ lambda{YggdrasilServer.command(%w{hoge})}.should raise_error(SystemExit)
55
+ end
56
+ err.should == "Unknown subcommand: 'hoge'\n"
57
+ end
58
+
59
+ help_help = <<"EOS"
60
+ help (?,h): Describe the usage of this program or its subcommands.
61
+ usage: #{File.basename($0)} help [SUBCOMMAND]
62
+
63
+ EOS
64
+
65
+ it 'should show help_help (server)' do
66
+ puts '---- should show help_help (server)'
67
+ out = catch_out{YggdrasilServer.command %w{help help}}
68
+ out.should == help_help
69
+ end
70
+
71
+ it 'should error too many arguments (server)' do
72
+ puts '---- should error too many arguments (server)'
73
+ err = catch_err do
74
+ lambda{YggdrasilServer.command(%w{help help help})}.should raise_error(SystemExit)
75
+ end
76
+ err.should == "#{File.basename($0)} error: too many arguments.\n\n"
77
+ end
78
+
79
+ it 'should show help of version (server)' do
80
+ puts '---- should show help of version (server)'
81
+ out = catch_out{YggdrasilServer.command %w{help version}}
82
+ out.should == <<"EOS"
83
+ version: See the program version
84
+ usage: #{File.basename($0)} version
85
+
86
+ EOS
87
+ end
88
+
89
+
90
+ it 'should show help of init (server)' do
91
+ puts '---- should show help of init (server)'
92
+ out = catch_out{YggdrasilServer.command %w{help init}}
93
+ out.should == <<"EOS"
94
+ init: setup yggdrasil server configuration.
95
+ usage: #{File.basename($0)} init [OPTIONS...]
96
+
97
+ Valid options:
98
+ --port ARG : specify a TCP port number ARG
99
+ --repo ARG : URL of subversion repository
100
+ ARG can contain {HOST} or a {host}
101
+ {HOST} is replaced by client hostname with domain
102
+ {host} is replaced by client hostname without domain
103
+ e.g. svn://192.168.3.5/servers/{host}/ygg
104
+ --ro-username ARG : specify a username ARG for read only
105
+ --ro-password ARG : specify a password ARG for read only
106
+
107
+ EOS
108
+ end
109
+
110
+ it 'should show help of debug (server)' do
111
+ puts '---- should show help of debug (server)'
112
+ out = catch_out{YggdrasilServer.command %w{help debug}}
113
+ out.should == <<"EOS"
114
+ debug: launch TCP server by debug mode.
115
+ usage: #{File.basename($0)} debug
116
+
117
+ EOS
118
+ end
119
+
120
+ it 'should show help of daemon (server)' do
121
+ puts '---- should show help of daemon (server)'
122
+ out = catch_out{YggdrasilServer.command %w{help daemon}}
123
+ out.should == <<"EOS"
124
+ daemon: launch TCP server by daemon mode.
125
+ usage: #{File.basename($0)} daemon
126
+
127
+ EOS
128
+ end
129
+
130
+ it 'should show help of results (server)' do
131
+ puts '---- should show help of results'
132
+ out = catch_out{YggdrasilServer.command %w{help results}}
133
+ out.should == <<"EOS"
134
+ results: display the result of yggdrasil check command.
135
+ usage: #{File.basename($0)} results [OPTIONS...]
136
+
137
+ Valid options:
138
+ --expire ARG : minutes from the final report, to judge the host not be alive
139
+
140
+ EOS
141
+ end
142
+ end
@@ -1,8 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'yggdrasil_server'
2
3
 
3
- describe Yggdrasil, "init-server" do
4
- it '-------- init-server' do
5
- puts '-------- init-server'
4
+ describe YggdrasilServer, 'init (server)' do
5
+ it '-------- init (server)' do
6
+ puts '-------- init (server)'
6
7
  prepare_environment
7
8
  end
8
9
 
@@ -10,7 +11,7 @@ describe Yggdrasil, "init-server" do
10
11
  `rm -rf /tmp/yggdrasil-test/.yggdrasil`
11
12
  puts '---- should error: "Not enough arguments provided"'
12
13
  err = catch_err do
13
- lambda{Yggdrasil.command(%w{init-server --repo})}.should raise_error(SystemExit)
14
+ lambda{YggdrasilServer.command(%w{init --repo})}.should raise_error(SystemExit)
14
15
  end
15
16
  err.should == "#{File.basename($0)} error: Not enough arguments provided: --repo\n\n"
16
17
  end
@@ -18,13 +19,13 @@ describe Yggdrasil, "init-server" do
18
19
  it 'should make server_config (all interactive)' do
19
20
  `rm -rf /tmp/yggdrasil-test/.yggdrasil`
20
21
  puts '---- should make server_config (all interactive)"'
21
- Yggdrasil.command %w{init-server},
22
+ YggdrasilServer.command %w{init},
22
23
  "4000\n"+ # tcp port
23
24
  "svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/\n"+ #svn repository
24
25
  "hoge\n"+ # read only username
25
26
  "foo\n" #read only password
26
27
 
27
- File.exists?("/tmp/yggdrasil-test/.yggdrasil/server_config").should be_true
28
+ File.exists?('/tmp/yggdrasil-test/.yggdrasil/server_config').should be_true
28
29
  `cat /tmp/yggdrasil-test/.yggdrasil/server_config`.should == <<"EOS"
29
30
  port=4000
30
31
  repo=svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}
@@ -36,13 +37,13 @@ EOS
36
37
  it 'should make server_config (all argument)' do
37
38
  `rm -rf /tmp/yggdrasil-test/.yggdrasil`
38
39
  puts '---- should make server_config (all interactive)"'
39
- Yggdrasil.command %w{init-server} +
40
+ YggdrasilServer.command %w{init} +
40
41
  %w{--port 4000} +
41
42
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
42
43
  %w{--ro-username hoge} +
43
44
  %w{--ro-password foo}
44
45
 
45
- File.exists?("/tmp/yggdrasil-test/.yggdrasil/server_config").should be_true
46
+ File.exists?('/tmp/yggdrasil-test/.yggdrasil/server_config').should be_true
46
47
  `cat /tmp/yggdrasil-test/.yggdrasil/server_config`.should == <<"EOS"
47
48
  port=4000
48
49
  repo=svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}
@@ -54,12 +55,12 @@ EOS
54
55
  it 'should make server_config (no ro-username)' do
55
56
  `rm -rf /tmp/yggdrasil-test/.yggdrasil`
56
57
  puts '---- should make server_config (all interactive)"'
57
- Yggdrasil.command %w{init-server} +
58
+ YggdrasilServer.command %w{init} +
58
59
  %w{--port 4000} +
59
60
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/},
60
61
  "\n" # prompt for input read only username
61
62
 
62
- File.exists?("/tmp/yggdrasil-test/.yggdrasil/server_config").should be_true
63
+ File.exists?('/tmp/yggdrasil-test/.yggdrasil/server_config').should be_true
63
64
  `cat /tmp/yggdrasil-test/.yggdrasil/server_config`.should == <<"EOS"
64
65
  port=4000
65
66
  repo=svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}
@@ -71,11 +72,11 @@ EOS
71
72
  puts '---- should error if argument have only password'
72
73
 
73
74
  err = catch_err do
74
- args = %w{init-server} +
75
+ args = %w{init} +
75
76
  %w{--port 4000} +
76
77
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
77
78
  %w{--ro-password foo}
78
- lambda{Yggdrasil.command(args)}.should raise_error(SystemExit)
79
+ lambda{YggdrasilServer.command(args)}.should raise_error(SystemExit)
79
80
  end
80
81
  err.should == "#{File.basename($0)} error: --ro-password option need --ro-username, too.\n\n"
81
82
  end
@@ -1,28 +1,29 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'yggdrasil_server'
2
3
 
3
- describe Yggdrasil, "results" do
4
+ describe YggdrasilServer, 'results' do
4
5
  before(:all) do
5
6
  puts '-------- results'
6
7
  prepare_environment
7
8
 
8
9
  sock = 0
9
10
  begin
10
- sock = TCPSocket.open("localhost", 4000)
11
+ sock = TCPSocket.open('localhost', 4000)
11
12
  rescue
12
- puts "OK. no server"
13
+ puts 'OK. no server'
13
14
  else
14
- puts "NG. zombie server. try quit"
15
- sock.puts("quit")
15
+ puts 'NG. zombie server. try quit'
16
+ sock.puts('quit')
16
17
  sock.close
17
18
  end
18
19
 
19
- Yggdrasil.command %w{init-server} +
20
+ YggdrasilServer.command %w{init} +
20
21
  %w{--port 4000} +
21
22
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/}+
22
23
  %w{--ro-username hoge --ro-password foo},
23
24
  "\n\n"
24
25
  fork do
25
- Yggdrasil.command %w{server --debug}
26
+ YggdrasilServer.command %w{debug}
26
27
  end
27
28
  sleep 1
28
29
  end
@@ -42,9 +43,9 @@ describe Yggdrasil, "results" do
42
43
  Yggdrasil.command %w{check}
43
44
  sleep 1
44
45
  out = catch_out do
45
- Yggdrasil.command %w{results --limit 30}
46
+ YggdrasilServer.command %w{results --expire 30}
46
47
  end
47
- out.should == ""
48
+ out.should == ''
48
49
  end
49
50
 
50
51
  it 'should show results' do
@@ -56,16 +57,16 @@ describe Yggdrasil, "results" do
56
57
  `echo hoge > /tmp/yggdrasil-test/.yggdrasil/results/hoge-old`
57
58
  File.utime Time.local(2001, 5, 22, 23, 59, 59),
58
59
  Time.local(2001, 5, 1, 0, 0, 0),
59
- "/tmp/yggdrasil-test/.yggdrasil/results/hoge-old"
60
+ '/tmp/yggdrasil-test/.yggdrasil/results/hoge-old'
60
61
  sleep 1
61
62
 
62
63
  out = catch_out do
63
- lambda{Yggdrasil.command(%w{results --limit 30})}.should raise_error(SystemExit)
64
+ lambda{YggdrasilServer.command(%w{results --expire 30})}.should raise_error(SystemExit)
64
65
  end
65
66
 
66
67
  out.should == <<"EOS"
67
68
  ######## hoge-old: last check is too old: 2001-05-01 00:00:00 +0900
68
- ######## centos6_127.0.0.1 Mismatch:
69
+ ######## #{Socket.gethostname}_127.0.0.1 Mismatch:
69
70
  M 2 tmp/yggdrasil-test/A
70
71
 
71
72
  Index: tmp/yggdrasil-test/A
@@ -80,8 +81,8 @@ EOS
80
81
 
81
82
  after(:all) do
82
83
  sleep 1
83
- sock = TCPSocket.open("localhost", 4000)
84
- sock.puts("quit")
84
+ sock = TCPSocket.open('localhost', 4000)
85
+ sock.puts('quit')
85
86
  sock.close
86
87
  Process.waitall
87
88
  end
data/spec/server_spec.rb CHANGED
@@ -1,117 +1,118 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
  require 'timeout'
3
3
  require 'socket'
4
+ require 'yggdrasil_server'
4
5
 
5
- describe Yggdrasil, "server" do
6
+ describe YggdrasilServer, 'server' do
6
7
 
7
8
  before(:all) do
8
9
  puts '-------- server'
9
10
  prepare_environment
10
- Yggdrasil.command %w{init-server} +
11
+ YggdrasilServer.command %w{init} +
11
12
  %w{--port 4000} +
12
13
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
13
14
  %w{--ro-username hoge} +
14
15
  %w{--ro-password foo}
15
16
  end
16
17
 
17
- it "should quit server on debug mode" do
18
- puts "---- should quit server on debug mode"
18
+ it 'should quit server on debug mode' do
19
+ puts '---- should quit server on debug mode'
19
20
 
20
21
  fork do
21
22
  # client behavior
22
23
  sleep 1
23
- sock = TCPSocket.open("localhost", 4000)
24
- sock.puts("quit")
24
+ sock = TCPSocket.open('localhost', 4000)
25
+ sock.puts('quit')
25
26
  sock.close
26
27
  exit
27
28
  end
28
29
 
29
30
  timeout 5 do
30
- Yggdrasil.command %w{server --debug}
31
+ YggdrasilServer.command %w{debug}
31
32
  end
32
33
 
33
34
  Process.waitall
34
35
  end
35
36
 
36
- it "should response repository URL" do
37
- puts "---- should response repository URL"
37
+ it 'should response repository URL' do
38
+ puts '---- should response repository URL'
38
39
 
39
40
  fork do
40
41
  sleep 1
41
- sock = TCPSocket.open("localhost", 4000)
42
- sock.puts("get_repo")
42
+ sock = TCPSocket.open('localhost', 4000)
43
+ sock.puts('get_repo')
43
44
  rcv = sock.gets
44
45
  rcv.should_not be_nil
45
46
  rcv.chomp!
46
- rcv.should == "svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}"
47
+ rcv.should == 'svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}'
47
48
  sock.close
48
49
 
49
- sock = TCPSocket.open("localhost", 4000)
50
- sock.puts("quit")
50
+ sock = TCPSocket.open('localhost', 4000)
51
+ sock.puts('quit')
51
52
  sock.close
52
53
  exit
53
54
  end
54
55
 
55
56
  timeout 5 do
56
- Yggdrasil.command %w{server --debug}
57
+ YggdrasilServer.command %w{debug}
57
58
  end
58
59
 
59
60
  Process.waitall
60
61
  end
61
62
 
62
- it "should response get_ro_id_pw" do
63
- puts "---- should response get_ro_id_pw"
63
+ it 'should response get_ro_id_pw' do
64
+ puts '---- should response get_ro_id_pw'
64
65
 
65
66
  fork do
66
67
  sleep 1
67
- sock = TCPSocket.open("localhost", 4000)
68
- sock.puts("get_ro_id_pw")
68
+ sock = TCPSocket.open('localhost', 4000)
69
+ sock.puts('get_ro_id_pw')
69
70
  username = sock.gets
70
71
  username.should_not be_nil
71
- username.chomp.should == "hoge"
72
+ username.chomp.should == 'hoge'
72
73
 
73
74
  password = sock.gets
74
75
  password.should_not be_nil
75
- password.chomp.should == "foo"
76
+ password.chomp.should == 'foo'
76
77
  sock.close
77
78
 
78
- sock = TCPSocket.open("localhost", 4000)
79
- sock.puts("quit")
79
+ sock = TCPSocket.open('localhost', 4000)
80
+ sock.puts('quit')
80
81
  sock.close
81
82
  exit
82
83
  end
83
84
 
84
85
  timeout 5 do
85
- Yggdrasil.command %w{server --debug}
86
+ YggdrasilServer.command %w{debug}
86
87
  end
87
88
 
88
89
  Process.waitall
89
90
  end
90
91
 
91
- it "should write file of check result to results directory" do
92
- puts "---- should write file of check result to results directory"
92
+ it 'should write file of check result to results directory' do
93
+ puts '---- should write file of check result to results directory'
93
94
 
94
95
  fork do
95
96
  sleep 1
96
- sock = TCPSocket.open("localhost", 4000)
97
- sock.puts("put_result HOSTNAME")
97
+ sock = TCPSocket.open('localhost', 4000)
98
+ sock.puts('put_result HOSTNAME')
98
99
  sock.puts <<"EOS"
99
100
  CHECK RESULTS................1
100
101
  CHECK RESULTS................2
101
102
  EOS
102
103
  sock.close
103
104
 
104
- sock = TCPSocket.open("localhost", 4000)
105
- sock.puts("quit")
105
+ sock = TCPSocket.open('localhost', 4000)
106
+ sock.puts('quit')
106
107
  sock.close
107
108
  exit
108
109
  end
109
110
 
110
111
  timeout 5 do
111
- Yggdrasil.command %w{server --debug}
112
+ YggdrasilServer.command %w{debug}
112
113
  end
113
114
 
114
- File.exist?("/tmp/yggdrasil-test/.yggdrasil/results/HOSTNAME_127.0.0.1").should be_true
115
+ File.exist?('/tmp/yggdrasil-test/.yggdrasil/results/HOSTNAME_127.0.0.1').should be_true
115
116
  `cat /tmp/yggdrasil-test/.yggdrasil/results/HOSTNAME_127.0.0.1`.should == <<"EOS"
116
117
  CHECK RESULTS................1
117
118
  CHECK RESULTS................2
@@ -120,37 +121,37 @@ EOS
120
121
  Process.waitall
121
122
  end
122
123
 
123
- it "should not response get_ro_id_pw" do
124
- puts "---- should not response get_ro_id_pw"
124
+ it 'should not response get_ro_id_pw' do
125
+ puts '---- should not response get_ro_id_pw'
125
126
  prepare_environment
126
- Yggdrasil.command %w{init-server} +
127
+ YggdrasilServer.command %w{init} +
127
128
  %w{--port 4000} +
128
129
  %w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/},
129
130
  "\n\n"
130
131
 
131
132
  fork do
132
133
  sleep 1
133
- sock = TCPSocket.open("localhost", 4000)
134
+ sock = TCPSocket.open('localhost', 4000)
134
135
  sock.puts("\n")
135
136
  no_res = sock.gets
136
137
  no_res.should be_nil
137
138
  sock.close
138
139
 
139
140
  sleep 1
140
- sock = TCPSocket.open("localhost", 4000)
141
- sock.puts("get_ro_id_pw")
141
+ sock = TCPSocket.open('localhost', 4000)
142
+ sock.puts('get_ro_id_pw')
142
143
  username = sock.gets
143
144
  username.should be_nil
144
145
  sock.close
145
146
 
146
- sock = TCPSocket.open("localhost", 4000)
147
- sock.puts("quit")
147
+ sock = TCPSocket.open('localhost', 4000)
148
+ sock.puts('quit')
148
149
  sock.close
149
150
  exit
150
151
  end
151
152
 
152
153
  timeout 5 do
153
- Yggdrasil.command %w{server --debug}
154
+ YggdrasilServer.command %w{debug}
154
155
  end
155
156
 
156
157
  Process.waitall
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'yggdrasil_server'
3
+
4
+ describe YggdrasilServer, 'version' do
5
+
6
+ show_version = <<"EOS"
7
+ #{File.basename($0)}, version #{Yggdrasil::VERSION}
8
+
9
+ Copyright (C) 2012-2013 Tomohisa Kusukawa.
10
+ Yggdrasil is open source software, see https://github.com/tkusukawa/yggdrasil/
11
+
12
+ EOS
13
+
14
+ it 'should show version on "version"' do
15
+ puts '---- should show version on "version"'
16
+ out = catch_out{YggdrasilServer.command %w{version}}
17
+ out.should == show_version
18
+ end
19
+
20
+ it 'should show version on "--version"' do
21
+ puts '---- should show version on "--version"'
22
+ out = catch_out{YggdrasilServer.command %w{--version}}
23
+ out.should == show_version
24
+ end
25
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../lib/yggdrasil'
2
2
 
3
3
  def prepare_environment
4
- puts "---- prepare environment"
4
+ puts '---- prepare environment'
5
5
 
6
6
  `pkill svnserve`
7
7
  `rm -rf /tmp/yggdrasil-test`
@@ -13,10 +13,10 @@ def prepare_environment
13
13
 
14
14
  puts '-- launch svnserve'
15
15
 
16
- File.open("/tmp/yggdrasil-test/svn-repo/conf/passwd", "w") do |f|
16
+ File.open('/tmp/yggdrasil-test/svn-repo/conf/passwd', 'w') do |f|
17
17
  f.write "[users]\nhoge = foo"
18
18
  end
19
- File.open("/tmp/yggdrasil-test/svn-repo/conf/svnserve.conf", "w") do |f|
19
+ File.open('/tmp/yggdrasil-test/svn-repo/conf/svnserve.conf', 'w') do |f|
20
20
  f.write <<"EOS"
21
21
  [general]
22
22
  anon-access = none