forked from yhara/myrurema
/
commands.rb
85 lines (70 loc) · 1.6 KB
/
commands.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
require File.expand_path("../src/myrurema", File.dirname(__FILE__))
class MyRurema
def sh(cmd, opt={})
@cmds ||= []
@cmds << cmd
end
attr_reader :cmds
end
CASES = {
"rurema --init" => [
%r{svn co .*doctree},
%r{svn co .*bitclust},
%r{bitclust.*init},
%r{bitclust.*update},
],
"rurema --init --rubyver=1.8.7" => [
%r{bitclust.*init version=1.8.7}
],
"rurema --init --ruremadir=/tmp" => [
%r{svn co .*/tmp}
],
"rurema --update" => [
%r{svn up},
%r{bitclust.*update}
],
"rurema Array" => [
%r{refe.*Array},
],
"rurema --server" => [
%r{standalone},
],
"rurema --server --port=9898" => [
%r{standalone.*--port=9898},
],
"rurema --server --browser" => [
%r{standalone},
%r{(start|open) http://localhost:}
],
# "rurema --edit" => [
# %r{cd .*doctree/refm/api/src},
# ],
"rurema --preview _builtin/Array" => [
%r{bc-tohtml.*_builtin/Array .*rurema_preview.html},
],
"rurema --preview _builtin/Array Array#pop" => [
%r{bc-tohtml.*_builtin/Array --target=Array#pop.*rurema_preview.html},
],
"rurema --preview Array --browser" => [
%r{bc-tohtml},
%r{(start|open) .*rurema_preview.html}
],
}
describe MyRurema do
it "should execute expected commands" do
CASES.each do |command, expects|
opt = Options.new(command.split[1..-1])
my = MyRurema.new(opt)
my.run
cmds = my.cmds
i = 0
expects.each do |pattern|
pattern.should satisfy{
i = cmds[i..-1].index{|cmd| pattern =~ cmd}
not i.nil?
}
i += 1
end
end
end
end