thor 0.16.0 → 1.2.1
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.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +15 -0
- data/README.md +23 -6
- data/bin/thor +1 -1
- data/lib/thor/actions/create_file.rb +34 -35
- data/lib/thor/actions/create_link.rb +9 -5
- data/lib/thor/actions/directory.rb +33 -23
- data/lib/thor/actions/empty_directory.rb +75 -85
- data/lib/thor/actions/file_manipulation.rb +103 -36
- data/lib/thor/actions/inject_into_file.rb +46 -36
- data/lib/thor/actions.rb +90 -68
- data/lib/thor/base.rb +302 -244
- data/lib/thor/command.rb +142 -0
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +52 -24
- data/lib/thor/error.rb +90 -10
- data/lib/thor/group.rb +70 -74
- data/lib/thor/invocation.rb +63 -55
- data/lib/thor/line_editor/basic.rb +37 -0
- data/lib/thor/line_editor/readline.rb +88 -0
- data/lib/thor/line_editor.rb +17 -0
- data/lib/thor/nested_context.rb +29 -0
- data/lib/thor/parser/argument.rb +24 -28
- data/lib/thor/parser/arguments.rb +110 -102
- data/lib/thor/parser/option.rb +53 -15
- data/lib/thor/parser/options.rb +174 -97
- data/lib/thor/parser.rb +4 -4
- data/lib/thor/rake_compat.rb +12 -11
- data/lib/thor/runner.rb +159 -155
- data/lib/thor/shell/basic.rb +216 -93
- data/lib/thor/shell/color.rb +53 -40
- data/lib/thor/shell/html.rb +61 -58
- data/lib/thor/shell.rb +29 -36
- data/lib/thor/util.rb +231 -213
- data/lib/thor/version.rb +1 -1
- data/lib/thor.rb +303 -166
- data/thor.gemspec +27 -24
- metadata +36 -226
- data/.gitignore +0 -44
- data/.rspec +0 -2
- data/.travis.yml +0 -7
- data/CHANGELOG.rdoc +0 -134
- data/Gemfile +0 -15
- data/Thorfile +0 -30
- data/bin/rake2thor +0 -86
- data/lib/thor/core_ext/dir_escape.rb +0 -0
- data/lib/thor/core_ext/file_binary_read.rb +0 -9
- data/lib/thor/core_ext/ordered_hash.rb +0 -100
- data/lib/thor/task.rb +0 -132
- data/spec/actions/create_file_spec.rb +0 -170
- data/spec/actions/create_link_spec.rb +0 -81
- data/spec/actions/directory_spec.rb +0 -149
- data/spec/actions/empty_directory_spec.rb +0 -130
- data/spec/actions/file_manipulation_spec.rb +0 -370
- data/spec/actions/inject_into_file_spec.rb +0 -135
- data/spec/actions_spec.rb +0 -331
- data/spec/base_spec.rb +0 -279
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +0 -43
- data/spec/core_ext/ordered_hash_spec.rb +0 -115
- data/spec/exit_condition_spec.rb +0 -19
- data/spec/fixtures/application.rb +0 -2
- data/spec/fixtures/app{1}/README +0 -3
- data/spec/fixtures/bundle/execute.rb +0 -6
- data/spec/fixtures/bundle/main.thor +0 -1
- data/spec/fixtures/doc/%file_name%.rb.tt +0 -1
- data/spec/fixtures/doc/COMMENTER +0 -10
- data/spec/fixtures/doc/README +0 -3
- data/spec/fixtures/doc/block_helper.rb +0 -3
- data/spec/fixtures/doc/components/.empty_directory +0 -0
- data/spec/fixtures/doc/config.rb +0 -1
- data/spec/fixtures/doc/config.yaml.tt +0 -1
- data/spec/fixtures/enum.thor +0 -10
- data/spec/fixtures/group.thor +0 -114
- data/spec/fixtures/invoke.thor +0 -112
- data/spec/fixtures/path with spaces +0 -0
- data/spec/fixtures/script.thor +0 -190
- data/spec/fixtures/task.thor +0 -10
- data/spec/group_spec.rb +0 -216
- data/spec/invocation_spec.rb +0 -100
- data/spec/parser/argument_spec.rb +0 -53
- data/spec/parser/arguments_spec.rb +0 -66
- data/spec/parser/option_spec.rb +0 -202
- data/spec/parser/options_spec.rb +0 -330
- data/spec/rake_compat_spec.rb +0 -72
- data/spec/register_spec.rb +0 -135
- data/spec/runner_spec.rb +0 -241
- data/spec/shell/basic_spec.rb +0 -300
- data/spec/shell/color_spec.rb +0 -81
- data/spec/shell/html_spec.rb +0 -32
- data/spec/shell_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -59
- data/spec/task_spec.rb +0 -80
- data/spec/thor_spec.rb +0 -418
- data/spec/util_spec.rb +0 -196
@@ -1,135 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require 'thor/actions'
|
3
|
-
|
4
|
-
describe Thor::Actions::InjectIntoFile do
|
5
|
-
before do
|
6
|
-
::FileUtils.rm_rf(destination_root)
|
7
|
-
::FileUtils.cp_r(source_root, destination_root)
|
8
|
-
end
|
9
|
-
|
10
|
-
def invoker(options={})
|
11
|
-
@invoker ||= MyCounter.new([1,2], options, { :destination_root => destination_root })
|
12
|
-
end
|
13
|
-
|
14
|
-
def revoker
|
15
|
-
@revoker ||= MyCounter.new([1,2], {}, { :destination_root => destination_root, :behavior => :revoke })
|
16
|
-
end
|
17
|
-
|
18
|
-
def invoke!(*args, &block)
|
19
|
-
capture(:stdout){ invoker.insert_into_file(*args, &block) }
|
20
|
-
end
|
21
|
-
|
22
|
-
def revoke!(*args, &block)
|
23
|
-
capture(:stdout){ revoker.insert_into_file(*args, &block) }
|
24
|
-
end
|
25
|
-
|
26
|
-
def file
|
27
|
-
File.join(destination_root, "doc/README")
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#invoke!" do
|
31
|
-
it "changes the file adding content after the flag" do
|
32
|
-
invoke! "doc/README", "\nmore content", :after => "__start__"
|
33
|
-
File.read(file).should == "__start__\nmore content\nREADME\n__end__\n"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "changes the file adding content before the flag" do
|
37
|
-
invoke! "doc/README", "more content\n", :before => "__end__"
|
38
|
-
File.read(file).should == "__start__\nREADME\nmore content\n__end__\n"
|
39
|
-
end
|
40
|
-
|
41
|
-
it "accepts data as a block" do
|
42
|
-
invoke! "doc/README", :before => "__end__" do
|
43
|
-
"more content\n"
|
44
|
-
end
|
45
|
-
|
46
|
-
File.read(file).should == "__start__\nREADME\nmore content\n__end__\n"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "logs status" do
|
50
|
-
invoke!("doc/README", "\nmore content", :after => "__start__").should == " insert doc/README\n"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "does not change the file if pretending" do
|
54
|
-
invoker :pretend => true
|
55
|
-
invoke! "doc/README", "\nmore content", :after => "__start__"
|
56
|
-
File.read(file).should == "__start__\nREADME\n__end__\n"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "does not change the file if already include content" do
|
60
|
-
invoke! "doc/README", :before => "__end__" do
|
61
|
-
"more content\n"
|
62
|
-
end
|
63
|
-
|
64
|
-
File.read(file).should == "__start__\nREADME\nmore content\n__end__\n"
|
65
|
-
|
66
|
-
invoke! "doc/README", :before => "__end__" do
|
67
|
-
"more content\n"
|
68
|
-
end
|
69
|
-
|
70
|
-
File.read(file).should == "__start__\nREADME\nmore content\n__end__\n"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "does change the file if already include content and :force == true" do
|
74
|
-
invoke! "doc/README", :before => "__end__" do
|
75
|
-
"more content\n"
|
76
|
-
end
|
77
|
-
|
78
|
-
File.read(file).should == "__start__\nREADME\nmore content\n__end__\n"
|
79
|
-
|
80
|
-
invoke! "doc/README", :before => "__end__", :force => true do
|
81
|
-
"more content\n"
|
82
|
-
end
|
83
|
-
|
84
|
-
File.read(file).should == "__start__\nREADME\nmore content\nmore content\n__end__\n"
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "#revoke!" do
|
90
|
-
it "substracts the destination file after injection" do
|
91
|
-
invoke! "doc/README", "\nmore content", :after => "__start__"
|
92
|
-
revoke! "doc/README", "\nmore content", :after => "__start__"
|
93
|
-
File.read(file).should == "__start__\nREADME\n__end__\n"
|
94
|
-
end
|
95
|
-
|
96
|
-
it "substracts the destination file before injection" do
|
97
|
-
invoke! "doc/README", "more content\n", :before => "__start__"
|
98
|
-
revoke! "doc/README", "more content\n", :before => "__start__"
|
99
|
-
File.read(file).should == "__start__\nREADME\n__end__\n"
|
100
|
-
end
|
101
|
-
|
102
|
-
it "substracts even with double after injection" do
|
103
|
-
invoke! "doc/README", "\nmore content", :after => "__start__"
|
104
|
-
invoke! "doc/README", "\nanother stuff", :after => "__start__"
|
105
|
-
revoke! "doc/README", "\nmore content", :after => "__start__"
|
106
|
-
File.read(file).should == "__start__\nanother stuff\nREADME\n__end__\n"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "substracts even with double before injection" do
|
110
|
-
invoke! "doc/README", "more content\n", :before => "__start__"
|
111
|
-
invoke! "doc/README", "another stuff\n", :before => "__start__"
|
112
|
-
revoke! "doc/README", "more content\n", :before => "__start__"
|
113
|
-
File.read(file).should == "another stuff\n__start__\nREADME\n__end__\n"
|
114
|
-
end
|
115
|
-
|
116
|
-
it "substracts when prepending" do
|
117
|
-
invoke! "doc/README", "more content\n", :after => /\A/
|
118
|
-
invoke! "doc/README", "another stuff\n", :after => /\A/
|
119
|
-
revoke! "doc/README", "more content\n", :after => /\A/
|
120
|
-
File.read(file).should == "another stuff\n__start__\nREADME\n__end__\n"
|
121
|
-
end
|
122
|
-
|
123
|
-
it "substracts when appending" do
|
124
|
-
invoke! "doc/README", "more content\n", :before => /\z/
|
125
|
-
invoke! "doc/README", "another stuff\n", :before => /\z/
|
126
|
-
revoke! "doc/README", "more content\n", :before => /\z/
|
127
|
-
File.read(file).should == "__start__\nREADME\n__end__\nanother stuff\n"
|
128
|
-
end
|
129
|
-
|
130
|
-
it "shows progress information to the user" do
|
131
|
-
invoke!("doc/README", "\nmore content", :after => "__start__")
|
132
|
-
revoke!("doc/README", "\nmore content", :after => "__start__").should == " subtract doc/README\n"
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
data/spec/actions_spec.rb
DELETED
@@ -1,331 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Thor::Actions do
|
4
|
-
def runner(options={})
|
5
|
-
@runner ||= MyCounter.new([1], options, { :destination_root => destination_root })
|
6
|
-
end
|
7
|
-
|
8
|
-
def action(*args, &block)
|
9
|
-
capture(:stdout){ runner.send(*args, &block) }
|
10
|
-
end
|
11
|
-
|
12
|
-
def file
|
13
|
-
File.join(destination_root, "foo")
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "on include" do
|
17
|
-
it "adds runtime options to the base class" do
|
18
|
-
MyCounter.class_options.keys.should include(:pretend)
|
19
|
-
MyCounter.class_options.keys.should include(:force)
|
20
|
-
MyCounter.class_options.keys.should include(:quiet)
|
21
|
-
MyCounter.class_options.keys.should include(:skip)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#initialize" do
|
26
|
-
it "has default behavior invoke" do
|
27
|
-
runner.behavior.should == :invoke
|
28
|
-
end
|
29
|
-
|
30
|
-
it "can have behavior revoke" do
|
31
|
-
MyCounter.new([1], {}, :behavior => :revoke).behavior.should == :revoke
|
32
|
-
end
|
33
|
-
|
34
|
-
it "when behavior is set to force, overwrite options" do
|
35
|
-
runner = MyCounter.new([1], { :force => false, :skip => true }, :behavior => :force)
|
36
|
-
runner.behavior.should == :invoke
|
37
|
-
runner.options.force.should be_true
|
38
|
-
runner.options.skip.should_not be_true
|
39
|
-
end
|
40
|
-
|
41
|
-
it "when behavior is set to skip, overwrite options" do
|
42
|
-
runner = MyCounter.new([1], ["--force"], :behavior => :skip)
|
43
|
-
runner.behavior.should == :invoke
|
44
|
-
runner.options.force.should_not be_true
|
45
|
-
runner.options.skip.should be_true
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "accessors" do
|
50
|
-
describe "#destination_root=" do
|
51
|
-
it "gets the current directory and expands the path to set the root" do
|
52
|
-
base = MyCounter.new([1])
|
53
|
-
base.destination_root = "here"
|
54
|
-
base.destination_root.should == File.expand_path(File.join(File.dirname(__FILE__), "..", "here"))
|
55
|
-
end
|
56
|
-
|
57
|
-
it "does not use the current directory if one is given" do
|
58
|
-
root = File.expand_path("/")
|
59
|
-
base = MyCounter.new([1])
|
60
|
-
base.destination_root = root
|
61
|
-
base.destination_root.should == root
|
62
|
-
end
|
63
|
-
|
64
|
-
it "uses the current directory if none is given" do
|
65
|
-
base = MyCounter.new([1])
|
66
|
-
base.destination_root.should == File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#relative_to_original_destination_root" do
|
71
|
-
it "returns the path relative to the absolute root" do
|
72
|
-
runner.relative_to_original_destination_root(file).should == "foo"
|
73
|
-
end
|
74
|
-
|
75
|
-
it "does not remove dot if required" do
|
76
|
-
runner.relative_to_original_destination_root(file, false).should == "./foo"
|
77
|
-
end
|
78
|
-
|
79
|
-
it "always use the absolute root" do
|
80
|
-
runner.inside("foo") do
|
81
|
-
runner.relative_to_original_destination_root(file).should == "foo"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
it "creates proper relative paths for absolute file location" do
|
86
|
-
runner.relative_to_original_destination_root('/test/file').should == "/test/file"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "does not fail with files constaining regexp characters" do
|
90
|
-
runner = MyCounter.new([1], {}, { :destination_root => File.join(destination_root, "fo[o-b]ar") })
|
91
|
-
runner.relative_to_original_destination_root("bar").should == "bar"
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#source_paths_for_search" do
|
95
|
-
it "add source_root to source_paths_for_search" do
|
96
|
-
MyCounter.source_paths_for_search.should include(File.expand_path("fixtures", File.dirname(__FILE__)))
|
97
|
-
end
|
98
|
-
|
99
|
-
it "keeps only current source root in source paths" do
|
100
|
-
ClearCounter.source_paths_for_search.should include(File.expand_path("fixtures/bundle", File.dirname(__FILE__)))
|
101
|
-
ClearCounter.source_paths_for_search.should_not include(File.expand_path("fixtures", File.dirname(__FILE__)))
|
102
|
-
end
|
103
|
-
|
104
|
-
it "customized source paths should be before source roots" do
|
105
|
-
ClearCounter.source_paths_for_search[0].should == File.expand_path("fixtures/doc", File.dirname(__FILE__))
|
106
|
-
ClearCounter.source_paths_for_search[1].should == File.expand_path("fixtures/bundle", File.dirname(__FILE__))
|
107
|
-
end
|
108
|
-
|
109
|
-
it "keeps inherited source paths at the end" do
|
110
|
-
ClearCounter.source_paths_for_search.last.should == File.expand_path("fixtures/broken", File.dirname(__FILE__))
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "#find_in_source_paths" do
|
116
|
-
it "raises an error if source path is empty" do
|
117
|
-
lambda {
|
118
|
-
A.new.find_in_source_paths("foo")
|
119
|
-
}.should raise_error(Thor::Error, /Currently you have no source paths/)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "finds a template inside the source path" do
|
123
|
-
runner.find_in_source_paths("doc").should == File.expand_path("doc", source_root)
|
124
|
-
lambda { runner.find_in_source_paths("README") }.should raise_error
|
125
|
-
|
126
|
-
new_path = File.join(source_root, "doc")
|
127
|
-
runner.instance_variable_set(:@source_paths, nil)
|
128
|
-
runner.source_paths.unshift(new_path)
|
129
|
-
runner.find_in_source_paths("README").should == File.expand_path("README", new_path)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "#inside" do
|
135
|
-
it "executes the block inside the given folder" do
|
136
|
-
runner.inside("foo") do
|
137
|
-
Dir.pwd.should == file
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
it "changes the base root" do
|
142
|
-
runner.inside("foo") do
|
143
|
-
runner.destination_root.should == file
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
it "creates the directory if it does not exist" do
|
148
|
-
runner.inside("foo") do
|
149
|
-
File.exists?(file).should be_true
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "when pretending" do
|
154
|
-
it "no directories should be created" do
|
155
|
-
runner.inside("bar", :pretend => true) {}
|
156
|
-
File.exists?("bar").should be_false
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "when verbose" do
|
161
|
-
it "logs status" do
|
162
|
-
capture(:stdout) do
|
163
|
-
runner.inside("foo", :verbose => true) {}
|
164
|
-
end.should =~ /inside foo/
|
165
|
-
end
|
166
|
-
|
167
|
-
it "uses padding in next status" do
|
168
|
-
capture(:stdout) do
|
169
|
-
runner.inside("foo", :verbose => true) do
|
170
|
-
runner.say_status :cool, :padding
|
171
|
-
end
|
172
|
-
end.should =~ /cool padding/
|
173
|
-
end
|
174
|
-
|
175
|
-
it "removes padding after block" do
|
176
|
-
capture(:stdout) do
|
177
|
-
runner.inside("foo", :verbose => true) {}
|
178
|
-
runner.say_status :no, :padding
|
179
|
-
end.should =~ /no padding/
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe "#in_root" do
|
185
|
-
it "executes the block in the root folder" do
|
186
|
-
runner.inside("foo") do
|
187
|
-
runner.in_root { Dir.pwd.should == destination_root }
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
it "changes the base root" do
|
192
|
-
runner.inside("foo") do
|
193
|
-
runner.in_root { runner.destination_root.should == destination_root }
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
it "returns to the previous state" do
|
198
|
-
runner.inside("foo") do
|
199
|
-
runner.in_root { }
|
200
|
-
runner.destination_root.should == file
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#apply" do
|
206
|
-
before do
|
207
|
-
@template = <<-TEMPLATE
|
208
|
-
@foo = "FOO"
|
209
|
-
say_status :cool, :padding
|
210
|
-
TEMPLATE
|
211
|
-
@template.stub(:read).and_return(@template)
|
212
|
-
|
213
|
-
@file = '/'
|
214
|
-
runner.stub(:open).and_return(@template)
|
215
|
-
end
|
216
|
-
|
217
|
-
it "accepts a URL as the path" do
|
218
|
-
@file = "http://gist.github.com/103208.txt"
|
219
|
-
runner.should_receive(:open).with(@file, "Accept" => "application/x-thor-template").and_return(@template)
|
220
|
-
action(:apply, @file)
|
221
|
-
end
|
222
|
-
|
223
|
-
it "accepts a secure URL as the path" do
|
224
|
-
@file = "https://gist.github.com/103208.txt"
|
225
|
-
runner.should_receive(:open).with(@file, "Accept" => "application/x-thor-template").and_return(@template)
|
226
|
-
action(:apply, @file)
|
227
|
-
end
|
228
|
-
|
229
|
-
it "accepts a local file path with spaces" do
|
230
|
-
@file = File.expand_path("fixtures/path with spaces", File.dirname(__FILE__))
|
231
|
-
runner.should_receive(:open).with(@file).and_return(@template)
|
232
|
-
action(:apply, @file)
|
233
|
-
end
|
234
|
-
|
235
|
-
it "opens a file and executes its content in the instance binding" do
|
236
|
-
action :apply, @file
|
237
|
-
runner.instance_variable_get("@foo").should == "FOO"
|
238
|
-
end
|
239
|
-
|
240
|
-
it "applies padding to the content inside the file" do
|
241
|
-
action(:apply, @file).should =~ /cool padding/
|
242
|
-
end
|
243
|
-
|
244
|
-
it "logs its status" do
|
245
|
-
action(:apply, @file).should =~ / apply #{@file}\n/
|
246
|
-
end
|
247
|
-
|
248
|
-
it "does not log status" do
|
249
|
-
content = action(:apply, @file, :verbose => false)
|
250
|
-
content.should =~ /cool padding/
|
251
|
-
content.should_not =~ /apply http/
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "#run" do
|
256
|
-
before do
|
257
|
-
runner.should_receive(:system).with("ls")
|
258
|
-
end
|
259
|
-
|
260
|
-
it "executes the command given" do
|
261
|
-
action :run, "ls"
|
262
|
-
end
|
263
|
-
|
264
|
-
it "logs status" do
|
265
|
-
action(:run, "ls").should == " run ls from \".\"\n"
|
266
|
-
end
|
267
|
-
|
268
|
-
it "does not log status if required" do
|
269
|
-
action(:run, "ls", :verbose => false).should be_empty
|
270
|
-
end
|
271
|
-
|
272
|
-
it "accepts a color as status" do
|
273
|
-
runner.shell.should_receive(:say_status).with(:run, 'ls from "."', :yellow)
|
274
|
-
action :run, "ls", :verbose => :yellow
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "#run_ruby_script" do
|
279
|
-
before do
|
280
|
-
Thor::Util.stub!(:ruby_command).and_return("/opt/jruby")
|
281
|
-
runner.should_receive(:system).with("/opt/jruby script.rb")
|
282
|
-
end
|
283
|
-
|
284
|
-
it "executes the ruby script" do
|
285
|
-
action :run_ruby_script, "script.rb"
|
286
|
-
end
|
287
|
-
|
288
|
-
it "logs status" do
|
289
|
-
action(:run_ruby_script, "script.rb").should == " run jruby script.rb from \".\"\n"
|
290
|
-
end
|
291
|
-
|
292
|
-
it "does not log status if required" do
|
293
|
-
action(:run_ruby_script, "script.rb", :verbose => false).should be_empty
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
describe "#thor" do
|
298
|
-
it "executes the thor command" do
|
299
|
-
runner.should_receive(:system).with("thor list")
|
300
|
-
action :thor, :list, :verbose => true
|
301
|
-
end
|
302
|
-
|
303
|
-
it "converts extra arguments to command arguments" do
|
304
|
-
runner.should_receive(:system).with("thor list foo bar")
|
305
|
-
action :thor, :list, "foo", "bar"
|
306
|
-
end
|
307
|
-
|
308
|
-
it "converts options hash to switches" do
|
309
|
-
runner.should_receive(:system).with("thor list foo bar --foo")
|
310
|
-
action :thor, :list, "foo", "bar", :foo => true
|
311
|
-
|
312
|
-
runner.should_receive(:system).with("thor list --foo 1 2 3")
|
313
|
-
action :thor, :list, :foo => [1,2,3]
|
314
|
-
end
|
315
|
-
|
316
|
-
it "logs status" do
|
317
|
-
runner.should_receive(:system).with("thor list")
|
318
|
-
action(:thor, :list).should == " run thor list from \".\"\n"
|
319
|
-
end
|
320
|
-
|
321
|
-
it "does not log status if required" do
|
322
|
-
runner.should_receive(:system).with("thor list --foo 1 2 3")
|
323
|
-
action(:thor, :list, :foo => [1,2,3], :verbose => false).should be_empty
|
324
|
-
end
|
325
|
-
|
326
|
-
it "captures the output when :capture is given" do
|
327
|
-
runner.should_receive(:`).with("thor foo bar")
|
328
|
-
action(:thor, "foo", "bar", :capture => true)
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|