thor 0.16.0 → 0.17.0
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/.rspec +1 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +8 -0
- data/Gemfile +12 -8
- data/lib/thor.rb +79 -10
- data/lib/thor/actions.rb +13 -13
- data/lib/thor/actions/directory.rb +29 -10
- data/lib/thor/actions/file_manipulation.rb +8 -2
- data/lib/thor/base.rb +24 -11
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +5 -0
- data/lib/thor/group.rb +5 -5
- data/lib/thor/parser/options.rb +63 -25
- data/lib/thor/rake_compat.rb +3 -2
- data/lib/thor/runner.rb +1 -1
- data/lib/thor/shell/basic.rb +16 -16
- data/lib/thor/shell/color.rb +9 -9
- data/lib/thor/shell/html.rb +9 -9
- data/lib/thor/task.rb +2 -2
- data/lib/thor/version.rb +1 -1
- data/spec/actions/create_file_spec.rb +30 -30
- data/spec/actions/create_link_spec.rb +12 -12
- data/spec/actions/directory_spec.rb +34 -27
- data/spec/actions/empty_directory_spec.rb +16 -16
- data/spec/actions/file_manipulation_spec.rb +62 -50
- data/spec/actions/inject_into_file_spec.rb +18 -18
- data/spec/actions_spec.rb +56 -56
- data/spec/base_spec.rb +69 -69
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +19 -14
- data/spec/core_ext/ordered_hash_spec.rb +29 -29
- data/spec/exit_condition_spec.rb +3 -3
- data/spec/fixtures/preserve/script.sh +3 -0
- data/spec/fixtures/script.thor +5 -0
- data/spec/group_spec.rb +55 -55
- data/spec/invocation_spec.rb +26 -26
- data/spec/parser/argument_spec.rb +12 -12
- data/spec/parser/arguments_spec.rb +12 -12
- data/spec/parser/option_spec.rb +47 -47
- data/spec/parser/options_spec.rb +137 -72
- data/spec/rake_compat_spec.rb +11 -11
- data/spec/register_spec.rb +70 -8
- data/spec/runner_spec.rb +38 -38
- data/spec/shell/basic_spec.rb +49 -37
- data/spec/shell/color_spec.rb +13 -13
- data/spec/shell/html_spec.rb +3 -3
- data/spec/shell_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -0
- data/spec/task_spec.rb +11 -11
- data/spec/thor_spec.rb +161 -91
- data/spec/util_spec.rb +42 -42
- data/thor.gemspec +1 -7
- metadata +8 -118
- data/lib/thor/core_ext/dir_escape.rb +0 -0
data/lib/thor/rake_compat.rb
CHANGED
@@ -6,12 +6,13 @@ class Thor
|
|
6
6
|
# rake package tasks. For example, to use rspec rake tasks, one can do:
|
7
7
|
#
|
8
8
|
# require 'thor/rake_compat'
|
9
|
+
# require 'rspec/core/rake_task'
|
9
10
|
#
|
10
11
|
# class Default < Thor
|
11
12
|
# include Thor::RakeCompat
|
12
13
|
#
|
13
|
-
#
|
14
|
-
# t.spec_opts = ['--options', "
|
14
|
+
# RSpec::Core::RakeTask.new(:spec) do |t|
|
15
|
+
# t.spec_opts = ['--options', "./.rspec"]
|
15
16
|
# t.spec_files = FileList['spec/**/*_spec.rb']
|
16
17
|
# end
|
17
18
|
# end
|
data/lib/thor/runner.rb
CHANGED
@@ -25,7 +25,7 @@ class Thor::Runner < Thor #:nodoc:
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# If a task is not found on Thor::Runner, method missing is invoked and
|
28
|
-
# Thor::Runner is then
|
28
|
+
# Thor::Runner is then responsible for finding the task in all classes.
|
29
29
|
#
|
30
30
|
def method_missing(meth, *args)
|
31
31
|
meth = meth.to_s
|
data/lib/thor/shell/basic.rb
CHANGED
@@ -58,7 +58,7 @@ class Thor
|
|
58
58
|
# ==== Example
|
59
59
|
# say("I know you knew that.")
|
60
60
|
#
|
61
|
-
def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)
|
61
|
+
def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)\Z/))
|
62
62
|
message = message.to_s
|
63
63
|
|
64
64
|
message = set_color(message, *color) if color
|
@@ -226,20 +226,20 @@ class Thor
|
|
226
226
|
answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}]
|
227
227
|
|
228
228
|
case answer
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
229
|
+
when is?(:yes), is?(:force), ""
|
230
|
+
return true
|
231
|
+
when is?(:no), is?(:skip)
|
232
|
+
return false
|
233
|
+
when is?(:always)
|
234
|
+
return @always_force = true
|
235
|
+
when is?(:quit)
|
236
|
+
say 'Aborting...'
|
237
|
+
raise SystemExit
|
238
|
+
when is?(:diff)
|
239
|
+
show_diff(destination, yield) if block_given?
|
240
|
+
say 'Retrying...'
|
241
|
+
else
|
242
|
+
say file_collision_help
|
243
243
|
end
|
244
244
|
end
|
245
245
|
end
|
@@ -370,7 +370,7 @@ HELP
|
|
370
370
|
|
371
371
|
def ask_simply(statement, color=nil)
|
372
372
|
say("#{statement} ", color)
|
373
|
-
stdin.gets.strip
|
373
|
+
stdin.gets.tap{|text| text.strip! if text}
|
374
374
|
end
|
375
375
|
|
376
376
|
def ask_filtered(statement, answer_set, *args)
|
data/lib/thor/shell/color.rb
CHANGED
@@ -112,15 +112,15 @@ class Thor
|
|
112
112
|
|
113
113
|
def output_diff_line(diff) #:nodoc:
|
114
114
|
case diff.action
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
115
|
+
when '-'
|
116
|
+
say "- #{diff.old_element.chomp}", :red, true
|
117
|
+
when '+'
|
118
|
+
say "+ #{diff.new_element.chomp}", :green, true
|
119
|
+
when '!'
|
120
|
+
say "- #{diff.old_element.chomp}", :red, true
|
121
|
+
say "+ #{diff.new_element.chomp}", :green, true
|
122
|
+
else
|
123
|
+
say " #{diff.old_element.chomp}", nil, true
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
data/lib/thor/shell/html.rb
CHANGED
@@ -91,15 +91,15 @@ class Thor
|
|
91
91
|
|
92
92
|
def output_diff_line(diff) #:nodoc:
|
93
93
|
case diff.action
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
94
|
+
when '-'
|
95
|
+
say "- #{diff.old_element.chomp}", :red, true
|
96
|
+
when '+'
|
97
|
+
say "+ #{diff.new_element.chomp}", :green, true
|
98
|
+
when '!'
|
99
|
+
say "- #{diff.old_element.chomp}", :red, true
|
100
|
+
say "+ #{diff.new_element.chomp}", :green, true
|
101
|
+
else
|
102
|
+
say " #{diff.old_element.chomp}", nil, true
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
data/lib/thor/task.rb
CHANGED
@@ -24,9 +24,9 @@ class Thor
|
|
24
24
|
instance.class.handle_no_task_error(name)
|
25
25
|
elsif public_method?(instance)
|
26
26
|
arity = instance.method(name).arity
|
27
|
-
instance.
|
27
|
+
instance.__send__(name, *args)
|
28
28
|
elsif local_method?(instance, :method_missing)
|
29
|
-
instance.
|
29
|
+
instance.__send__(:method_missing, name.to_sym, *args)
|
30
30
|
else
|
31
31
|
instance.class.handle_no_task_error(name)
|
32
32
|
end
|
data/lib/thor/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe Thor::Actions::CreateFile do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_file(destination=nil, config={}, options={})
|
10
|
-
@base = MyCounter.new([1,2], options, { :destination_root => destination_root })
|
10
|
+
@base = MyCounter.new([1, 2], options, { :destination_root => destination_root })
|
11
11
|
@base.stub!(:file_name).and_return('rdoc')
|
12
12
|
|
13
13
|
@action = Thor::Actions::CreateFile.new(@base, destination, "CONFIGURATION",
|
@@ -15,11 +15,11 @@ describe Thor::Actions::CreateFile do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def invoke!
|
18
|
-
capture(:stdout){ @action.invoke! }
|
18
|
+
capture(:stdout) { @action.invoke! }
|
19
19
|
end
|
20
20
|
|
21
21
|
def revoke!
|
22
|
-
capture(:stdout){ @action.revoke! }
|
22
|
+
capture(:stdout) { @action.revoke! }
|
23
23
|
end
|
24
24
|
|
25
25
|
def silence!
|
@@ -30,36 +30,36 @@ describe Thor::Actions::CreateFile do
|
|
30
30
|
it "creates a file" do
|
31
31
|
create_file("doc/config.rb")
|
32
32
|
invoke!
|
33
|
-
File.exists?(File.join(destination_root, "doc/config.rb")).
|
33
|
+
expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_true
|
34
34
|
end
|
35
35
|
|
36
36
|
it "does not create a file if pretending" do
|
37
37
|
create_file("doc/config.rb", {}, :pretend => true)
|
38
38
|
invoke!
|
39
|
-
File.exists?(File.join(destination_root, "doc/config.rb")).
|
39
|
+
expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_false
|
40
40
|
end
|
41
41
|
|
42
42
|
it "shows created status to the user" do
|
43
43
|
create_file("doc/config.rb")
|
44
|
-
invoke
|
44
|
+
expect(invoke!).to eq(" create doc/config.rb\n")
|
45
45
|
end
|
46
46
|
|
47
47
|
it "does not show any information if log status is false" do
|
48
48
|
silence!
|
49
49
|
create_file("doc/config.rb")
|
50
|
-
invoke
|
50
|
+
expect(invoke!).to be_empty
|
51
51
|
end
|
52
52
|
|
53
53
|
it "returns the given destination" do
|
54
54
|
capture(:stdout) do
|
55
|
-
create_file("doc/config.rb").invoke
|
55
|
+
expect(create_file("doc/config.rb").invoke!).to eq("doc/config.rb")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
it "converts encoded instructions" do
|
60
60
|
create_file("doc/%file_name%.rb.tt")
|
61
61
|
invoke!
|
62
|
-
File.exists?(File.join(destination_root, "doc/rdoc.rb.tt")).
|
62
|
+
expect(File.exists?(File.join(destination_root, "doc/rdoc.rb.tt"))).to be_true
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "when file exists" do
|
@@ -72,7 +72,7 @@ describe Thor::Actions::CreateFile do
|
|
72
72
|
it "shows identical status" do
|
73
73
|
create_file("doc/config.rb")
|
74
74
|
invoke!
|
75
|
-
invoke
|
75
|
+
expect(invoke!).to eq(" identical doc/config.rb\n")
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -82,46 +82,46 @@ describe Thor::Actions::CreateFile do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "shows forced status to the user if force is given" do
|
85
|
-
create_file("doc/config.rb", {}, :force => true).
|
86
|
-
invoke
|
85
|
+
expect(create_file("doc/config.rb", {}, :force => true)).not_to be_identical
|
86
|
+
expect(invoke!).to eq(" force doc/config.rb\n")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "shows skipped status to the user if skip is given" do
|
90
|
-
create_file("doc/config.rb", {}, :skip => true).
|
91
|
-
invoke
|
90
|
+
expect(create_file("doc/config.rb", {}, :skip => true)).not_to be_identical
|
91
|
+
expect(invoke!).to eq(" skip doc/config.rb\n")
|
92
92
|
end
|
93
93
|
|
94
94
|
it "shows forced status to the user if force is configured" do
|
95
|
-
create_file("doc/config.rb", :force => true).
|
96
|
-
invoke
|
95
|
+
expect(create_file("doc/config.rb", :force => true)).not_to be_identical
|
96
|
+
expect(invoke!).to eq(" force doc/config.rb\n")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "shows skipped status to the user if skip is configured" do
|
100
|
-
create_file("doc/config.rb", :skip => true).
|
101
|
-
invoke
|
100
|
+
expect(create_file("doc/config.rb", :skip => true)).not_to be_identical
|
101
|
+
expect(invoke!).to eq(" skip doc/config.rb\n")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "shows conflict status to ther user" do
|
105
|
-
create_file("doc/config.rb").
|
105
|
+
expect(create_file("doc/config.rb")).not_to be_identical
|
106
106
|
$stdin.should_receive(:gets).and_return('s')
|
107
107
|
file = File.join(destination_root, 'doc/config.rb')
|
108
108
|
|
109
109
|
content = invoke!
|
110
|
-
content.
|
111
|
-
content.
|
112
|
-
content.
|
110
|
+
expect(content).to match(/conflict doc\/config\.rb/)
|
111
|
+
expect(content).to match(/Overwrite #{file}\? \(enter "h" for help\) \[Ynaqdh\]/)
|
112
|
+
expect(content).to match(/skip doc\/config\.rb/)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "creates the file if the file collision menu returns true" do
|
116
116
|
create_file("doc/config.rb")
|
117
117
|
$stdin.should_receive(:gets).and_return('y')
|
118
|
-
invoke
|
118
|
+
expect(invoke!).to match(/force doc\/config\.rb/)
|
119
119
|
end
|
120
120
|
|
121
121
|
it "skips the file if the file collision menu returns false" do
|
122
122
|
create_file("doc/config.rb")
|
123
123
|
$stdin.should_receive(:gets).and_return('n')
|
124
|
-
invoke
|
124
|
+
expect(invoke!).to match(/skip doc\/config\.rb/)
|
125
125
|
end
|
126
126
|
|
127
127
|
it "executes the block given to show file content" do
|
@@ -140,31 +140,31 @@ describe Thor::Actions::CreateFile do
|
|
140
140
|
create_file("doc/config.rb")
|
141
141
|
invoke!
|
142
142
|
revoke!
|
143
|
-
File.exists?(@action.destination).
|
143
|
+
expect(File.exists?(@action.destination)).to be_false
|
144
144
|
end
|
145
145
|
|
146
146
|
it "does not raise an error if the file does not exist" do
|
147
147
|
create_file("doc/config.rb")
|
148
148
|
revoke!
|
149
|
-
File.exists?(@action.destination).
|
149
|
+
expect(File.exists?(@action.destination)).to be_false
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "#exists?" do
|
154
154
|
it "returns true if the destination file exists" do
|
155
155
|
create_file("doc/config.rb")
|
156
|
-
@action.exists
|
156
|
+
expect(@action.exists?).to be_false
|
157
157
|
invoke!
|
158
|
-
@action.exists
|
158
|
+
expect(@action.exists?).to be_true
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
describe "#identical?" do
|
163
163
|
it "returns true if the destination file and is identical" do
|
164
164
|
create_file("doc/config.rb")
|
165
|
-
@action.identical
|
165
|
+
expect(@action.identical?).to be_false
|
166
166
|
invoke!
|
167
|
-
@action.identical
|
167
|
+
expect(@action.identical?).to be_true
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -20,7 +20,7 @@ describe Thor::Actions::CreateLink do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def invoke!
|
23
|
-
capture(:stdout){ @action.invoke! }
|
23
|
+
capture(:stdout) { @action.invoke! }
|
24
24
|
end
|
25
25
|
|
26
26
|
def silence!
|
@@ -32,50 +32,50 @@ describe Thor::Actions::CreateLink do
|
|
32
32
|
create_link("doc/config.rb", :symbolic => true)
|
33
33
|
invoke!
|
34
34
|
destination_path = File.join(destination_root, "doc/config.rb")
|
35
|
-
File.exists?(destination_path).
|
36
|
-
File.symlink?(destination_path).
|
35
|
+
expect(File.exists?(destination_path)).to be_true
|
36
|
+
expect(File.symlink?(destination_path)).to be_true
|
37
37
|
end
|
38
38
|
|
39
39
|
it "creates a hard link for :symbolic => false" do
|
40
40
|
create_link(@hardlink_to, :symbolic => false)
|
41
41
|
invoke!
|
42
42
|
destination_path = @hardlink_to
|
43
|
-
File.exists?(destination_path).
|
44
|
-
File.symlink?(destination_path).
|
43
|
+
expect(File.exists?(destination_path)).to be_true
|
44
|
+
expect(File.symlink?(destination_path)).to be_false
|
45
45
|
end
|
46
46
|
|
47
47
|
it "creates a symbolic link by default" do
|
48
48
|
create_link("doc/config.rb")
|
49
49
|
invoke!
|
50
50
|
destination_path = File.join(destination_root, "doc/config.rb")
|
51
|
-
File.exists?(destination_path).
|
52
|
-
File.symlink?(destination_path).
|
51
|
+
expect(File.exists?(destination_path)).to be_true
|
52
|
+
expect(File.symlink?(destination_path)).to be_true
|
53
53
|
end
|
54
54
|
|
55
55
|
it "does not create a link if pretending" do
|
56
56
|
create_link("doc/config.rb", {}, :pretend => true)
|
57
57
|
invoke!
|
58
|
-
File.exists?(File.join(destination_root, "doc/config.rb")).
|
58
|
+
expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_false
|
59
59
|
end
|
60
60
|
|
61
61
|
it "shows created status to the user" do
|
62
62
|
create_link("doc/config.rb")
|
63
|
-
invoke
|
63
|
+
expect(invoke!).to eq(" create doc/config.rb\n")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "does not show any information if log status is false" do
|
67
67
|
silence!
|
68
68
|
create_link("doc/config.rb")
|
69
|
-
invoke
|
69
|
+
expect(invoke!).to be_empty
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
describe "#identical?" do
|
74
74
|
it "returns true if the destination link exists and is identical" do
|
75
75
|
create_link("doc/config.rb")
|
76
|
-
@action.identical
|
76
|
+
expect(@action.identical?).to be_false
|
77
77
|
invoke!
|
78
|
-
@action.identical
|
78
|
+
expect(@action.identical?).to be_true
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -28,21 +28,21 @@ describe Thor::Actions::Directory do
|
|
28
28
|
source = File.join(source_root, source_path, file)
|
29
29
|
destination = File.join(destination_root, destination_path, file)
|
30
30
|
|
31
|
-
File.exists?(destination).
|
32
|
-
FileUtils.identical?(source, destination).
|
31
|
+
expect(File.exists?(destination)).to be_true
|
32
|
+
expect(FileUtils.identical?(source, destination)).to be_true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#invoke!" do
|
37
37
|
it "raises an error if the source does not exist" do
|
38
|
-
|
38
|
+
expect {
|
39
39
|
invoke! "unknown"
|
40
|
-
}.
|
40
|
+
}.to raise_error(Thor::Error, /Could not find "unknown" in any of your source paths/)
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "does not create a directory in pretend mode" do
|
44
44
|
invoke! "doc", "ghost", :pretend => true
|
45
|
-
File.exists?("ghost").
|
45
|
+
expect(File.exists?("ghost")).to be_false
|
46
46
|
end
|
47
47
|
|
48
48
|
it "copies the whole directory recursively to the default destination" do
|
@@ -59,13 +59,13 @@ describe Thor::Actions::Directory do
|
|
59
59
|
invoke! ".", "tasks", :recursive => false
|
60
60
|
|
61
61
|
file = File.join(destination_root, "tasks", "group.thor")
|
62
|
-
File.exists?(file).
|
62
|
+
expect(File.exists?(file)).to be_true
|
63
63
|
|
64
64
|
file = File.join(destination_root, "tasks", "doc")
|
65
|
-
File.exists?(file).
|
65
|
+
expect(File.exists?(file)).to be_false
|
66
66
|
|
67
67
|
file = File.join(destination_root, "tasks", "doc", "README")
|
68
|
-
File.exists?(file).
|
68
|
+
expect(File.exists?(file)).to be_false
|
69
69
|
end
|
70
70
|
|
71
71
|
it "copies files from the source relative to the current path" do
|
@@ -78,40 +78,47 @@ describe Thor::Actions::Directory do
|
|
78
78
|
it "copies and evaluates templates" do
|
79
79
|
invoke! "doc", "docs"
|
80
80
|
file = File.join(destination_root, "docs", "rdoc.rb")
|
81
|
-
File.exists?(file).
|
82
|
-
File.read(file).
|
81
|
+
expect(File.exists?(file)).to be_true
|
82
|
+
expect(File.read(file)).to eq("FOO = FOO\n")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "copies directories and preserved file mode" do
|
86
|
+
invoke! "preserve", "preserved", :mode => :preserve
|
87
|
+
original = File.join(source_root, "preserve", "script.sh")
|
88
|
+
copy = File.join(destination_root, "preserved", "script.sh")
|
89
|
+
expect(File.stat(original).mode).to eq(File.stat(copy).mode)
|
83
90
|
end
|
84
91
|
|
85
92
|
it "copies directories" do
|
86
93
|
invoke! "doc", "docs"
|
87
94
|
file = File.join(destination_root, "docs", "components")
|
88
|
-
File.exists?(file).
|
89
|
-
File.directory?(file).
|
95
|
+
expect(File.exists?(file)).to be_true
|
96
|
+
expect(File.directory?(file)).to be_true
|
90
97
|
end
|
91
98
|
|
92
99
|
it "does not copy .empty_directory files" do
|
93
100
|
invoke! "doc", "docs"
|
94
101
|
file = File.join(destination_root, "docs", "components", ".empty_directory")
|
95
|
-
File.exists?(file).
|
102
|
+
expect(File.exists?(file)).to be_false
|
96
103
|
end
|
97
104
|
|
98
105
|
it "copies directories even if they are empty" do
|
99
106
|
invoke! "doc/components", "docs/components"
|
100
107
|
file = File.join(destination_root, "docs", "components")
|
101
|
-
File.exists?(file).
|
108
|
+
expect(File.exists?(file)).to be_true
|
102
109
|
end
|
103
110
|
|
104
111
|
it "does not copy empty directories twice" do
|
105
112
|
content = invoke!("doc/components", "docs/components")
|
106
|
-
content.
|
113
|
+
expect(content).not_to match(/exist/)
|
107
114
|
end
|
108
115
|
|
109
116
|
it "logs status" do
|
110
117
|
content = invoke!("doc")
|
111
|
-
content.
|
112
|
-
content.
|
113
|
-
content.
|
114
|
-
content.
|
118
|
+
expect(content).to match(/create doc\/README/)
|
119
|
+
expect(content).to match(/create doc\/config\.rb/)
|
120
|
+
expect(content).to match(/create doc\/rdoc\.rb/)
|
121
|
+
expect(content).to match(/create doc\/components/)
|
115
122
|
end
|
116
123
|
|
117
124
|
it "yields a block" do
|
@@ -119,12 +126,12 @@ describe Thor::Actions::Directory do
|
|
119
126
|
invoke!("doc") do |content|
|
120
127
|
checked ||= !!(content =~ /FOO/)
|
121
128
|
end
|
122
|
-
checked.
|
129
|
+
expect(checked).to be_true
|
123
130
|
end
|
124
131
|
|
125
132
|
it "works with glob characters in the path" do
|
126
133
|
content = invoke!("app{1}")
|
127
|
-
content.
|
134
|
+
expect(content).to match(/create app\{1\}\/README/)
|
128
135
|
end
|
129
136
|
end
|
130
137
|
|
@@ -133,17 +140,17 @@ describe Thor::Actions::Directory do
|
|
133
140
|
invoke! "doc"
|
134
141
|
revoke! "doc"
|
135
142
|
|
136
|
-
File.exists?(File.join(destination_root, "doc", "README")).
|
137
|
-
File.exists?(File.join(destination_root, "doc", "config.rb")).
|
138
|
-
File.exists?(File.join(destination_root, "doc", "components")).
|
143
|
+
expect(File.exists?(File.join(destination_root, "doc", "README"))).to be_false
|
144
|
+
expect(File.exists?(File.join(destination_root, "doc", "config.rb"))).to be_false
|
145
|
+
expect(File.exists?(File.join(destination_root, "doc", "components"))).to be_false
|
139
146
|
end
|
140
147
|
|
141
148
|
it "works with glob characters in the path" do
|
142
149
|
invoke! "app{1}"
|
143
|
-
File.exists?(File.join(destination_root, "app{1}", "README")).
|
150
|
+
expect(File.exists?(File.join(destination_root, "app{1}", "README"))).to be_true
|
144
151
|
|
145
152
|
revoke! "app{1}"
|
146
|
-
File.exists?(File.join(destination_root, "app{1}", "README")).
|
153
|
+
expect(File.exists?(File.join(destination_root, "app{1}", "README"))).to be_false
|
147
154
|
end
|
148
155
|
end
|
149
156
|
end
|