@@ -175,6 +175,46 @@ def shell
175
175
end
176
176
end
177
177
178
+ describe "#print_wrapped" do
179
+ let ( :message ) do
180
+ "Creates a back-up of the given folder by compressing it in a .tar.gz\n " \
181
+ "file and then uploading it to the configured Amazon S3 Bucket.\n \n " \
182
+ "It does not verify the integrity of the generated back-up."
183
+ end
184
+
185
+ before do
186
+ allow ( ENV ) . to receive ( :[] ) . with ( "THOR_COLUMNS" ) . and_return ( 80 )
187
+ end
188
+
189
+ context "without indentation" do
190
+ subject ( :wrap_text ) { described_class . new . print_wrapped ( message ) }
191
+
192
+ let ( :expected_output ) do
193
+ "Creates a back-up of the given folder by compressing it in a .tar.gz file and\n " \
194
+ "then uploading it to the configured Amazon S3 Bucket.\n \n " \
195
+ "It does not verify the integrity of the generated back-up.\n "
196
+ end
197
+
198
+ it "properly wraps the text around the 80th column" do
199
+ expect { wrap_text } . to output ( expected_output ) . to_stdout
200
+ end
201
+ end
202
+
203
+ context "with indentation" do
204
+ subject ( :wrap_text ) { described_class . new . print_wrapped ( message , :indent => 4 ) }
205
+
206
+ let ( :expected_output ) do
207
+ " Creates a back-up of the given folder by compressing it in a .tar.gz file\n " \
208
+ " and then uploading it to the configured Amazon S3 Bucket.\n \n " \
209
+ " It does not verify the integrity of the generated back-up.\n "
210
+ end
211
+
212
+ it "properly wraps the text around the 80th column" do
213
+ expect { wrap_text } . to output ( expected_output ) . to_stdout
214
+ end
215
+ end
216
+ end
217
+
178
218
describe "#say_status" do
179
219
it "prints a message to the user with status" do
180
220
expect ( $stdout) . to receive ( :print ) . with ( " create ~/.thor/command.thor\n " )
0 commit comments