-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathinvoker_spec.rb
80 lines (67 loc) · 1.67 KB
/
invoker_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
$:.unshift "spec/"
require 'xiki/core/invoker'
require './spec/spec_helper'
# describe Invoker, "#expand" do
describe Invoker, "#actionify" do
it "single action" do
Invoker.actionify(["bb"], [true]).should == ["bb", []]
end
it "second arg is action" do
Invoker.actionify(["act", "b"], [nil, true]).should == ["b", ["act"]]
end
it "one action, one param" do
Invoker.actionify(["act", "b"], [true, nil]).should == ["act", ["b"]]
end
it "two actions" do
Invoker.actionify(["act", "act2", "b"], [true, true, nil]).should == ["act2", ["b"]]
end
it "doesn't mess up the args" do
args = ["Hey you"]
Invoker.actionify(args, [true, true, nil]).should == ["hey_you", []]
args.should == ["Hey you"]
end
end
describe Invoker, "#extract_ruby_module" do
it "no module" do
Invoker.extract_ruby_module("
class Foo
end
".unindent).should == nil
end
it "extracts one module" do
Invoker.extract_ruby_module("
module Modern
class Foo
end
end
".unindent).should == "Modern"
end
it "extracts two modules" do
Invoker.extract_ruby_module("
module Modern
module Modest
class Foo
end
end
end
".unindent).should == "Modern::Modest"
end
it "isn't confused by stuff after start of class" do
Invoker.extract_ruby_module("
module Modern
# stuff
class Foo
end
module Herring
end
end
".unindent).should == "Modern"
end
it "handles when all on one line" do
Invoker.extract_ruby_module("
class Modern::Foo
# stuff
end
".unindent).should == "Modern"
end
end