thor 0.14.4 → 0.14.5
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/CHANGELOG.rdoc +11 -0
- data/Thorfile +9 -55
- data/lib/thor.rb +17 -0
- data/lib/thor/actions.rb +11 -6
- data/lib/thor/actions/create_file.rb +2 -2
- data/lib/thor/actions/create_link.rb +57 -0
- data/lib/thor/actions/file_manipulation.rb +36 -12
- data/lib/thor/actions/inject_into_file.rb +15 -10
- data/lib/thor/parser/option.rb +1 -1
- data/lib/thor/task.rb +1 -1
- data/lib/thor/version.rb +1 -1
- data/spec/actions/create_file_spec.rb +27 -27
- data/spec/actions/directory_spec.rb +23 -23
- data/spec/actions/empty_directory_spec.rb +12 -12
- data/spec/actions/file_manipulation_spec.rb +65 -42
- data/spec/actions/inject_into_file_spec.rb +24 -24
- data/spec/actions_spec.rb +63 -58
- data/spec/base_spec.rb +60 -60
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +14 -14
- data/spec/core_ext/ordered_hash_spec.rb +28 -28
- data/spec/group_spec.rb +39 -39
- data/spec/invocation_spec.rb +21 -21
- data/spec/parser/argument_spec.rb +7 -7
- data/spec/parser/arguments_spec.rb +11 -11
- data/spec/parser/option_spec.rb +45 -45
- data/spec/parser/options_spec.rb +75 -75
- data/spec/rake_compat_spec.rb +10 -10
- data/spec/register_spec.rb +92 -0
- data/spec/runner_spec.rb +32 -32
- data/spec/shell/basic_spec.rb +18 -18
- data/spec/shell/color_spec.rb +3 -3
- data/spec/shell_spec.rb +10 -10
- data/spec/spec_helper.rb +9 -10
- data/spec/task_spec.rb +8 -8
- data/spec/thor_spec.rb +62 -62
- data/spec/util_spec.rb +35 -35
- metadata +100 -68
- data/spec/spec.opts +0 -1
data/spec/runner_spec.rb
CHANGED
@@ -4,88 +4,88 @@ require 'thor/runner'
|
|
4
4
|
describe Thor::Runner do
|
5
5
|
describe "#help" do
|
6
6
|
it "shows information about Thor::Runner itself" do
|
7
|
-
capture(:stdout){ Thor::Runner.start(["help"]) }.
|
7
|
+
capture(:stdout){ Thor::Runner.start(["help"]) }.should =~ /List the available thor tasks/
|
8
8
|
end
|
9
9
|
|
10
10
|
it "shows information about an specific Thor::Runner task" do
|
11
11
|
content = capture(:stdout){ Thor::Runner.start(["help", "list"]) }
|
12
|
-
content.
|
13
|
-
content.
|
12
|
+
content.should =~ /List the available thor tasks/
|
13
|
+
content.should_not =~ /help \[TASK\]/
|
14
14
|
end
|
15
15
|
|
16
16
|
it "shows information about a specific Thor class" do
|
17
17
|
content = capture(:stdout){ Thor::Runner.start(["help", "my_script"]) }
|
18
|
-
content.
|
18
|
+
content.should =~ /zoo\s+# zoo around/m
|
19
19
|
end
|
20
20
|
|
21
21
|
it "shows information about an specific task from an specific Thor class" do
|
22
22
|
content = capture(:stdout){ Thor::Runner.start(["help", "my_script:zoo"]) }
|
23
|
-
content.
|
24
|
-
content.
|
23
|
+
content.should =~ /zoo around/
|
24
|
+
content.should_not =~ /help \[TASK\]/
|
25
25
|
end
|
26
26
|
|
27
27
|
it "shows information about a specific Thor group class" do
|
28
28
|
content = capture(:stdout){ Thor::Runner.start(["help", "my_counter"]) }
|
29
|
-
content.
|
29
|
+
content.should =~ /my_counter N/
|
30
30
|
end
|
31
31
|
|
32
32
|
it "raises error if a class/task cannot be found" do
|
33
33
|
content = capture(:stderr){ Thor::Runner.start(["help", "unknown"]) }
|
34
|
-
content.strip.
|
34
|
+
content.strip.should == 'Could not find task "unknown" in "default" namespace.'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#start" do
|
39
39
|
it "invokes a task from Thor::Runner" do
|
40
40
|
ARGV.replace ["list"]
|
41
|
-
capture(:stdout){ Thor::Runner.start }.
|
41
|
+
capture(:stdout){ Thor::Runner.start }.should =~ /my_counter N/
|
42
42
|
end
|
43
43
|
|
44
44
|
it "invokes a task from a specific Thor class" do
|
45
45
|
ARGV.replace ["my_script:zoo"]
|
46
|
-
Thor::Runner.start.
|
46
|
+
Thor::Runner.start.should be_true
|
47
47
|
end
|
48
48
|
|
49
49
|
it "invokes the default task from a specific Thor class if none is specified" do
|
50
50
|
ARGV.replace ["my_script"]
|
51
|
-
Thor::Runner.start.
|
51
|
+
Thor::Runner.start.should == "default task"
|
52
52
|
end
|
53
53
|
|
54
54
|
it "forwads arguments to the invoked task" do
|
55
55
|
ARGV.replace ["my_script:animal", "horse"]
|
56
|
-
Thor::Runner.start.
|
56
|
+
Thor::Runner.start.should == ["horse"]
|
57
57
|
end
|
58
58
|
|
59
59
|
it "invokes tasks through shortcuts" do
|
60
60
|
ARGV.replace ["my_script", "-T", "horse"]
|
61
|
-
Thor::Runner.start.
|
61
|
+
Thor::Runner.start.should == ["horse"]
|
62
62
|
end
|
63
63
|
|
64
64
|
it "invokes a Thor::Group" do
|
65
65
|
ARGV.replace ["my_counter", "1", "2", "--third", "3"]
|
66
|
-
Thor::Runner.start.
|
66
|
+
Thor::Runner.start.should == [1, 2, 3]
|
67
67
|
end
|
68
68
|
|
69
69
|
it "raises an error if class/task can't be found" do
|
70
70
|
ARGV.replace ["unknown"]
|
71
71
|
content = capture(:stderr){ Thor::Runner.start }
|
72
|
-
content.strip.
|
72
|
+
content.strip.should == 'Could not find task "unknown" in "default" namespace.'
|
73
73
|
end
|
74
74
|
|
75
75
|
it "does not swallow NoMethodErrors that occur inside the called method" do
|
76
76
|
ARGV.replace ["my_script:call_unexistent_method"]
|
77
|
-
lambda { Thor::Runner.start }.
|
77
|
+
lambda { Thor::Runner.start }.should raise_error(NoMethodError)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "does not swallow Thor::Group InvocationError" do
|
81
81
|
ARGV.replace ["whiny_generator"]
|
82
|
-
lambda { Thor::Runner.start }.
|
82
|
+
lambda { Thor::Runner.start }.should raise_error(ArgumentError, /Are you sure it has arity equals to 0\?/)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "does not swallow Thor InvocationError" do
|
86
86
|
ARGV.replace ["my_script:animal"]
|
87
87
|
content = capture(:stderr) { Thor::Runner.start }
|
88
|
-
content.strip.
|
88
|
+
content.strip.should == '"animal" was called incorrectly. Call as "thor my_script:animal TYPE".'
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -112,53 +112,53 @@ describe Thor::Runner do
|
|
112
112
|
it "gives a list of the available tasks" do
|
113
113
|
ARGV.replace ["list"]
|
114
114
|
content = capture(:stdout) { Thor::Runner.start }
|
115
|
-
content.
|
115
|
+
content.should =~ /amazing:describe NAME\s+# say that someone is amazing/m
|
116
116
|
end
|
117
117
|
|
118
118
|
it "gives a list of the available Thor::Group classes" do
|
119
119
|
ARGV.replace ["list"]
|
120
|
-
capture(:stdout) { Thor::Runner.start }.
|
120
|
+
capture(:stdout) { Thor::Runner.start }.should =~ /my_counter N/
|
121
121
|
end
|
122
122
|
|
123
123
|
it "can filter a list of the available tasks by --group" do
|
124
124
|
ARGV.replace ["list", "--group", "standard"]
|
125
|
-
capture(:stdout) { Thor::Runner.start }.
|
125
|
+
capture(:stdout) { Thor::Runner.start }.should =~ /amazing:describe NAME/
|
126
126
|
ARGV.replace []
|
127
|
-
capture(:stdout) { Thor::Runner.start }.
|
127
|
+
capture(:stdout) { Thor::Runner.start }.should_not =~ /my_script:animal TYPE/
|
128
128
|
ARGV.replace ["list", "--group", "script"]
|
129
|
-
capture(:stdout) { Thor::Runner.start }.
|
129
|
+
capture(:stdout) { Thor::Runner.start }.should =~ /my_script:animal TYPE/
|
130
130
|
end
|
131
131
|
|
132
132
|
it "can skip all filters to show all tasks using --all" do
|
133
133
|
ARGV.replace ["list", "--all"]
|
134
134
|
content = capture(:stdout) { Thor::Runner.start }
|
135
|
-
content.
|
136
|
-
content.
|
135
|
+
content.should =~ /amazing:describe NAME/
|
136
|
+
content.should =~ /my_script:animal TYPE/
|
137
137
|
end
|
138
138
|
|
139
139
|
it "doesn't list superclass tasks in the subclass" do
|
140
140
|
ARGV.replace ["list"]
|
141
|
-
capture(:stdout) { Thor::Runner.start }.
|
141
|
+
capture(:stdout) { Thor::Runner.start }.should_not =~ /amazing:help/
|
142
142
|
end
|
143
143
|
|
144
144
|
it "presents tasks in the default namespace with an empty namespace" do
|
145
145
|
ARGV.replace ["list"]
|
146
|
-
capture(:stdout) { Thor::Runner.start }.
|
146
|
+
capture(:stdout) { Thor::Runner.start }.should =~ /^thor :cow\s+# prints 'moo'/m
|
147
147
|
end
|
148
148
|
|
149
149
|
it "runs tasks with an empty namespace from the default namespace" do
|
150
150
|
ARGV.replace [":task_conflict"]
|
151
|
-
capture(:stdout) { Thor::Runner.start }.
|
151
|
+
capture(:stdout) { Thor::Runner.start }.should == "task\n"
|
152
152
|
end
|
153
153
|
|
154
154
|
it "runs groups even when there is a task with the same name" do
|
155
155
|
ARGV.replace ["task_conflict"]
|
156
|
-
capture(:stdout) { Thor::Runner.start }.
|
156
|
+
capture(:stdout) { Thor::Runner.start }.should == "group\n"
|
157
157
|
end
|
158
158
|
|
159
159
|
it "runs tasks with no colon in the default namespace" do
|
160
160
|
ARGV.replace ["cow"]
|
161
|
-
capture(:stdout) { Thor::Runner.start }.
|
161
|
+
capture(:stdout) { Thor::Runner.start }.should == "moo\n"
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -180,8 +180,8 @@ describe Thor::Runner do
|
|
180
180
|
|
181
181
|
it "displays the modules installed in a pretty way" do
|
182
182
|
stdout = capture(:stdout) { Thor::Runner.start(["installed"]) }
|
183
|
-
stdout.
|
184
|
-
stdout.
|
183
|
+
stdout.should =~ /random\s*amazing/
|
184
|
+
stdout.should =~ /amazing:describe NAME\s+# say that someone is amazing/m
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
data/spec/shell/basic_spec.rb
CHANGED
@@ -8,10 +8,10 @@ describe Thor::Shell::Basic do
|
|
8
8
|
describe "#padding" do
|
9
9
|
it "cannot be set to below zero" do
|
10
10
|
shell.padding = 10
|
11
|
-
shell.padding.
|
11
|
+
shell.padding.should == 10
|
12
12
|
|
13
13
|
shell.padding = -1
|
14
|
-
shell.padding.
|
14
|
+
shell.padding.should == 0
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,7 +19,7 @@ describe Thor::Shell::Basic do
|
|
19
19
|
it "prints a message to the user and gets the response" do
|
20
20
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
21
21
|
$stdin.should_receive(:gets).and_return('Sure')
|
22
|
-
shell.ask("Should I overwrite it?").
|
22
|
+
shell.ask("Should I overwrite it?").should == "Sure"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,11 +27,11 @@ describe Thor::Shell::Basic do
|
|
27
27
|
it "asks the user and returns true if the user replies yes" do
|
28
28
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
29
29
|
$stdin.should_receive(:gets).and_return('y')
|
30
|
-
shell.yes?("Should I overwrite it?").
|
30
|
+
shell.yes?("Should I overwrite it?").should === true
|
31
31
|
|
32
32
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
33
33
|
$stdin.should_receive(:gets).and_return('n')
|
34
|
-
shell.yes?("Should I overwrite it?").
|
34
|
+
shell.yes?("Should I overwrite it?").should_not === true
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,11 +39,11 @@ describe Thor::Shell::Basic do
|
|
39
39
|
it "asks the user and returns true if the user replies no" do
|
40
40
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
41
41
|
$stdin.should_receive(:gets).and_return('n')
|
42
|
-
shell.no?("Should I overwrite it?").
|
42
|
+
shell.no?("Should I overwrite it?").should === true
|
43
43
|
|
44
44
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
45
45
|
$stdin.should_receive(:gets).and_return('Yes')
|
46
|
-
shell.no?("Should I overwrite it?").
|
46
|
+
shell.no?("Should I overwrite it?").should === false
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -115,7 +115,7 @@ describe Thor::Shell::Basic do
|
|
115
115
|
|
116
116
|
it "prints a table" do
|
117
117
|
content = capture(:stdout){ shell.print_table(@table) }
|
118
|
-
content.
|
118
|
+
content.should == <<-TABLE
|
119
119
|
abc #123 first three
|
120
120
|
#0 empty
|
121
121
|
xyz #786 last three
|
@@ -124,7 +124,7 @@ TABLE
|
|
124
124
|
|
125
125
|
it "prints a table with identation" do
|
126
126
|
content = capture(:stdout){ shell.print_table(@table, :ident => 2) }
|
127
|
-
content.
|
127
|
+
content.should == <<-TABLE
|
128
128
|
abc #123 first three
|
129
129
|
#0 empty
|
130
130
|
xyz #786 last three
|
@@ -134,7 +134,7 @@ TABLE
|
|
134
134
|
it "uses maximum terminal width" do
|
135
135
|
shell.should_receive(:terminal_width).and_return(20)
|
136
136
|
content = capture(:stdout){ shell.print_table(@table, :ident => 2, :truncate => true) }
|
137
|
-
content.
|
137
|
+
content.should == <<-TABLE
|
138
138
|
abc #123 firs...
|
139
139
|
#0 empty
|
140
140
|
xyz #786 last...
|
@@ -143,7 +143,7 @@ TABLE
|
|
143
143
|
|
144
144
|
it "honors the colwidth option" do
|
145
145
|
content = capture(:stdout){ shell.print_table(@table, :colwidth => 10)}
|
146
|
-
content.
|
146
|
+
content.should == <<-TABLE
|
147
147
|
abc #123 first three
|
148
148
|
#0 empty
|
149
149
|
xyz #786 last three
|
@@ -161,19 +161,19 @@ TABLE
|
|
161
161
|
it "returns true if the user choose default option" do
|
162
162
|
$stdout.stub!(:print)
|
163
163
|
$stdin.should_receive(:gets).and_return('')
|
164
|
-
shell.file_collision('foo').
|
164
|
+
shell.file_collision('foo').should be_true
|
165
165
|
end
|
166
166
|
|
167
167
|
it "returns false if the user choose no" do
|
168
168
|
$stdout.stub!(:print)
|
169
169
|
$stdin.should_receive(:gets).and_return('n')
|
170
|
-
shell.file_collision('foo').
|
170
|
+
shell.file_collision('foo').should be_false
|
171
171
|
end
|
172
172
|
|
173
173
|
it "returns true if the user choose yes" do
|
174
174
|
$stdout.stub!(:print)
|
175
175
|
$stdin.should_receive(:gets).and_return('y')
|
176
|
-
shell.file_collision('foo').
|
176
|
+
shell.file_collision('foo').should be_true
|
177
177
|
end
|
178
178
|
|
179
179
|
it "shows help usage if the user choose help" do
|
@@ -181,7 +181,7 @@ TABLE
|
|
181
181
|
$stdin.should_receive(:gets).and_return('h')
|
182
182
|
$stdin.should_receive(:gets).and_return('n')
|
183
183
|
help = capture(:stdout){ shell.file_collision('foo') }
|
184
|
-
help.
|
184
|
+
help.should =~ /h \- help, show this help/
|
185
185
|
end
|
186
186
|
|
187
187
|
it "quits if the user choose quit" do
|
@@ -191,17 +191,17 @@ TABLE
|
|
191
191
|
|
192
192
|
lambda {
|
193
193
|
shell.file_collision('foo')
|
194
|
-
}.
|
194
|
+
}.should raise_error(SystemExit)
|
195
195
|
end
|
196
196
|
|
197
197
|
it "always returns true if the user choose always" do
|
198
198
|
$stdout.should_receive(:print).with('Overwrite foo? (enter "h" for help) [Ynaqh] ')
|
199
199
|
$stdin.should_receive(:gets).and_return('a')
|
200
200
|
|
201
|
-
shell.file_collision('foo').
|
201
|
+
shell.file_collision('foo').should be_true
|
202
202
|
|
203
203
|
$stdout.should_not_receive(:print)
|
204
|
-
shell.file_collision('foo').
|
204
|
+
shell.file_collision('foo').should be_true
|
205
205
|
end
|
206
206
|
|
207
207
|
describe "when a block is given" do
|
data/spec/shell/color_spec.rb
CHANGED
@@ -32,9 +32,9 @@ describe Thor::Shell::Color do
|
|
32
32
|
$stdin.should_receive(:gets).and_return('n')
|
33
33
|
|
34
34
|
output = capture(:stdout){ shell.file_collision('spec/fixtures/doc/README'){ "README\nEND\n" } }
|
35
|
-
output.
|
36
|
-
output.
|
37
|
-
output.
|
35
|
+
output.should =~ /\e\[31m\- __start__\e\[0m/
|
36
|
+
output.should =~ /^ README/
|
37
|
+
output.should =~ /\e\[32m\+ END\e\[0m/
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/spec/shell_spec.rb
CHANGED
@@ -8,30 +8,30 @@ describe Thor::Shell do
|
|
8
8
|
describe "#initialize" do
|
9
9
|
it "sets shell value" do
|
10
10
|
base = MyCounter.new [1, 2], { }, :shell => shell
|
11
|
-
base.shell.
|
11
|
+
base.shell.should == shell
|
12
12
|
end
|
13
13
|
|
14
14
|
it "sets the base value on the shell if an accessor is available" do
|
15
15
|
base = MyCounter.new [1, 2], { }, :shell => shell
|
16
|
-
shell.base.
|
16
|
+
shell.base.should == base
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "#shell" do
|
21
21
|
it "returns the shell in use" do
|
22
|
-
MyCounter.new([1,2]).shell.
|
22
|
+
MyCounter.new([1,2]).shell.should be_kind_of(Thor::Base.shell)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "uses $THOR_SHELL" do
|
26
26
|
class Thor::Shell::TestShell < Thor::Shell::Basic; end
|
27
|
-
|
28
|
-
Thor::Base.shell.
|
27
|
+
|
28
|
+
Thor::Base.shell.should == shell.class
|
29
29
|
ENV['THOR_SHELL'] = 'TestShell'
|
30
30
|
Thor::Base.shell = nil
|
31
|
-
Thor::Base.shell.
|
31
|
+
Thor::Base.shell.should == Thor::Shell::TestShell
|
32
32
|
ENV['THOR_SHELL'] = ''
|
33
33
|
Thor::Base.shell = shell.class
|
34
|
-
Thor::Base.shell.
|
34
|
+
Thor::Base.shell.should == shell.class
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,9 +39,9 @@ describe Thor::Shell do
|
|
39
39
|
it "uses padding for inside block outputs" do
|
40
40
|
base = MyCounter.new([1,2])
|
41
41
|
base.with_padding do
|
42
|
-
capture(:stdout){ base.say_status :padding, "cool" }.strip.
|
42
|
+
capture(:stdout){ base.say_status :padding, "cool" }.strip.should == "padding cool"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
$TESTING=true
|
2
2
|
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_group 'Libraries', 'lib'
|
6
|
+
add_group 'Specs', 'spec'
|
7
|
+
end
|
8
|
+
|
3
9
|
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
4
10
|
require 'thor'
|
5
11
|
require 'thor/group'
|
6
12
|
require 'stringio'
|
7
13
|
|
8
|
-
require 'rubygems'
|
9
14
|
require 'rdoc'
|
15
|
+
require 'rspec'
|
10
16
|
require 'diff/lcs' # You need diff/lcs installed to run specs (but not to run Thor).
|
11
17
|
require 'fakeweb' # You need fakeweb installed to run specs (but not to run Thor).
|
12
18
|
|
@@ -22,21 +28,14 @@ load File.join(File.dirname(__FILE__), "fixtures", "group.thor")
|
|
22
28
|
load File.join(File.dirname(__FILE__), "fixtures", "script.thor")
|
23
29
|
load File.join(File.dirname(__FILE__), "fixtures", "invoke.thor")
|
24
30
|
|
25
|
-
|
26
|
-
alias_method :must, :should
|
27
|
-
alias_method :must_not, :should_not
|
28
|
-
undef_method :should
|
29
|
-
undef_method :should_not
|
30
|
-
end
|
31
|
-
|
32
|
-
Spec::Runner.configure do |config|
|
31
|
+
RSpec.configure do |config|
|
33
32
|
def capture(stream)
|
34
33
|
begin
|
35
34
|
stream = stream.to_s
|
36
35
|
eval "$#{stream} = StringIO.new"
|
37
36
|
yield
|
38
37
|
result = eval("$#{stream}").string
|
39
|
-
ensure
|
38
|
+
ensure
|
40
39
|
eval("$#{stream} = #{stream.upcase}")
|
41
40
|
end
|
42
41
|
|
data/spec/task_spec.rb
CHANGED
@@ -13,28 +13,28 @@ describe Thor::Task do
|
|
13
13
|
it "includes namespace within usage" do
|
14
14
|
Object.stub!(:namespace).and_return("foo")
|
15
15
|
Object.stub!(:arguments).and_return([])
|
16
|
-
task(:bar => :required).formatted_usage(Object).
|
16
|
+
task(:bar => :required).formatted_usage(Object).should == "foo:can_has --bar=BAR"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "removes default from namespace" do
|
20
20
|
Object.stub!(:namespace).and_return("default:foo")
|
21
21
|
Object.stub!(:arguments).and_return([])
|
22
|
-
task(:bar => :required).formatted_usage(Object).
|
22
|
+
task(:bar => :required).formatted_usage(Object).should == ":foo:can_has --bar=BAR"
|
23
23
|
end
|
24
24
|
|
25
25
|
it "injects arguments into usage" do
|
26
26
|
Object.stub!(:namespace).and_return("foo")
|
27
27
|
Object.stub!(:arguments).and_return([ Thor::Argument.new(:bar, nil, true, :string) ])
|
28
|
-
task(:foo => :required).formatted_usage(Object).
|
28
|
+
task(:foo => :required).formatted_usage(Object).should == "foo:can_has BAR --foo=FOO"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe "#dynamic" do
|
33
33
|
it "creates a dynamic task with the given name" do
|
34
|
-
Thor::DynamicTask.new('task').name.
|
35
|
-
Thor::DynamicTask.new('task').description.
|
36
|
-
Thor::DynamicTask.new('task').usage.
|
37
|
-
Thor::DynamicTask.new('task').options.
|
34
|
+
Thor::DynamicTask.new('task').name.should == 'task'
|
35
|
+
Thor::DynamicTask.new('task').description.should == 'A dynamically-generated task'
|
36
|
+
Thor::DynamicTask.new('task').usage.should == 'task'
|
37
|
+
Thor::DynamicTask.new('task').options.should == {}
|
38
38
|
end
|
39
39
|
|
40
40
|
it "does not invoke an existing method" do
|
@@ -48,7 +48,7 @@ describe Thor::Task do
|
|
48
48
|
it "dup options hash" do
|
49
49
|
task = Thor::Task.new("can_has", nil, nil, nil, :foo => true, :bar => :required)
|
50
50
|
task.dup.options.delete(:foo)
|
51
|
-
task.options[:foo].
|
51
|
+
task.options[:foo].should_not be_nil
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|