File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,17 @@ def invoke_with_conflict_check(&block)
114
114
if exists?
115
115
on_conflict_behavior ( &block )
116
116
else
117
- say_status :create , :green
118
117
yield unless pretend?
118
+ say_status :create , :green
119
119
end
120
120
121
121
destination
122
+ rescue Errno ::EISDIR , Errno ::EEXIST
123
+ on_file_clash_behavior
124
+ end
125
+
126
+ def on_file_clash_behavior
127
+ say_status :file_clash , :red
122
128
end
123
129
124
130
# What to do when the destination file already exists.
Original file line number Diff line number Diff line change @@ -131,6 +131,30 @@ def silence!
131
131
end
132
132
end
133
133
end
134
+
135
+ context "when file exists and it causes a file clash" do
136
+ before do
137
+ create_file ( "doc/config" )
138
+ invoke!
139
+ end
140
+
141
+ it "generates a file clash" do
142
+ create_file ( "doc/config/config.rb" )
143
+ expect ( invoke! ) . to eq ( " file_clash doc/config/config.rb\n " )
144
+ end
145
+ end
146
+
147
+ context "when directory exists and it causes a file clash" do
148
+ before do
149
+ create_file ( "doc/config/hello" )
150
+ invoke!
151
+ end
152
+
153
+ it "generates a file clash" do
154
+ create_file ( "doc/config" )
155
+ expect ( invoke! ) . to eq ( " file_clash doc/config\n " )
156
+ end
157
+ end
134
158
end
135
159
136
160
describe "#revoke!" do
You can’t perform that action at this time.
0 commit comments