@@ -7,10 +7,10 @@ def encode_base64(str)
77
88def check_decoded ( actual , expected )
99 if RUBY_VERSION >= '1.9'
10- actual . encoding . should eq Encoding ::BINARY
11- actual . should eq expected . force_encoding ( Encoding ::BINARY )
10+ expect ( actual . encoding ) . to eq Encoding ::BINARY
11+ expect ( actual ) . to eq expected . force_encoding ( Encoding ::BINARY )
1212 else
13- actual . should eq expected
13+ expect ( actual ) . to eq expected
1414 end
1515end
1616
@@ -24,51 +24,51 @@ def check_decoded(actual, expected)
2424 describe "from direct content" do
2525 it "should work" do
2626 @mail . attachments [ 'test.png' ] = @test_png
27- @mail . attachments [ 'test.png' ] . filename . should eq 'test.png'
27+ expect ( @mail . attachments [ 'test.png' ] . filename ) . to eq 'test.png'
2828 check_decoded ( @mail . attachments [ 0 ] . decoded , @test_png )
2929 end
3030
3131 it "should work out magically the mime_type" do
3232 @mail . attachments [ 'test.png' ] = @test_png
33- @mail . attachments [ 0 ] . mime_type . should eq 'image/png'
33+ expect ( @mail . attachments [ 0 ] . mime_type ) . to eq 'image/png'
3434 end
3535
3636 it "should assign the filename" do
3737 @mail . attachments [ 'test.png' ] = @test_png
38- @mail . attachments [ 0 ] . filename . should eq 'test.png'
38+ expect ( @mail . attachments [ 0 ] . filename ) . to eq 'test.png'
3939 end
4040
4141 it "should assign mime-encoded multibyte filename" do
4242 @mail . attachments [ 'てすと.txt' ] = File . open ( fixture ( 'attachments' , 'てすと.txt' ) , 'rb' , &:read )
43- @mail . attachments . should_not be_blank
44- Mail ::Encodings . decode_encode ( @mail . attachments [ 0 ] . filename , :decode ) . should eq 'てすと.txt'
43+ expect ( @mail . attachments ) . not_to be_blank
44+ expect ( Mail ::Encodings . decode_encode ( @mail . attachments [ 0 ] . filename , :decode ) ) . to eq 'てすと.txt'
4545 end
4646 end
4747
4848 describe "from a supplied Hash" do
4949 it "should work" do
5050 @mail . attachments [ 'test.png' ] = { :content => @test_png }
51- @mail . attachments [ 0 ] . filename . should eq 'test.png'
51+ expect ( @mail . attachments [ 0 ] . filename ) . to eq 'test.png'
5252 check_decoded ( @mail . attachments [ 0 ] . decoded , @test_png )
5353 end
5454
5555 it "should allow you to override the content_type" do
5656 @mail . attachments [ 'test.png' ] = { :content => @test_png ,
5757 :content_type => "application/x-gzip" }
58- @mail . attachments [ 0 ] . content_type . should eq 'application/x-gzip'
58+ expect ( @mail . attachments [ 0 ] . content_type ) . to eq 'application/x-gzip'
5959 end
6060
6161 it "should allow you to override the mime_type" do
6262 @mail . attachments [ 'test.png' ] = { :content => @test_png ,
6363 :mime_type => "application/x-gzip" }
64- @mail . attachments [ 0 ] . mime_type . should eq 'application/x-gzip'
64+ expect ( @mail . attachments [ 0 ] . mime_type ) . to eq 'application/x-gzip'
6565 end
6666
6767 it "should allow you to override the mime_type" do
6868 @mail . attachments [ 'invoice.jpg' ] = { :data => "you smiling" ,
6969 :mime_type => "image/x-jpg" ,
7070 :transfer_encoding => "base64" }
71- @mail . attachments [ 0 ] . mime_type . should eq 'image/x-jpg'
71+ expect ( @mail . attachments [ 0 ] . mime_type ) . to eq 'image/x-jpg'
7272 end
7373
7474 end
@@ -78,13 +78,13 @@ def check_decoded(actual, expected)
7878 it "should set its content_transfer_encoding" do
7979 @mail . attachments [ 'test.png' ] = { :content => @test_png }
8080 @mail . ready_to_send!
81- @mail . attachments [ 0 ] . content_transfer_encoding . should eq 'base64'
81+ expect ( @mail . attachments [ 0 ] . content_transfer_encoding ) . to eq 'base64'
8282 end
8383
8484 it "should encode its body to base64" do
8585 @mail . attachments [ 'test.png' ] = { :content => @test_png }
8686 @mail . ready_to_send!
87- @mail . attachments [ 0 ] . encoded . should include ( encode_base64 ( @test_png ) )
87+ expect ( @mail . attachments [ 0 ] . encoded ) . to include ( encode_base64 ( @test_png ) )
8888 end
8989
9090 it "should allow you to pass in an encoded attachment with an encoding" do
@@ -97,14 +97,14 @@ def check_decoded(actual, expected)
9797 it "should allow you set a mime type and encoding without overriding the encoding" do
9898 encoded = encode_base64 ( '<foo/>' )
9999 @mail . attachments [ 'test.png' ] = { :mime_type => 'text/xml' , :content => encoded , :encoding => 'base64' }
100- @mail . attachments [ 0 ] . content_transfer_encoding . should eq 'base64'
100+ expect ( @mail . attachments [ 0 ] . content_transfer_encoding ) . to eq 'base64'
101101 check_decoded ( @mail . attachments [ 0 ] . decoded , '<foo/>' )
102102 end
103103
104104 it "should not allow you to pass in an encoded attachment with an unknown encoding" do
105105 base64_encoded_data = encode_base64 ( @test_png )
106- doing { @mail . attachments [ 'test.png' ] = { :content => base64_encoded_data ,
107- :encoding => 'weird_encoding' } } . should raise_error
106+ expect ( doing { @mail . attachments [ 'test.png' ] = { :content => base64_encoded_data ,
107+ :encoding => 'weird_encoding' } } ) . to raise_error
108108 end
109109
110110 it "should be able to call read on the attachment to return the decoded data" do
@@ -114,15 +114,15 @@ def check_decoded(actual, expected)
114114 else
115115 expected = @mail . attachments [ 0 ] . read
116116 end
117- expected . should eq @test_png
117+ expect ( expected ) . to eq @test_png
118118 end
119119
120120 it "should only add one newline between attachment body and boundary" do
121121 contents = "I have\n two lines with trailing newlines\n \n "
122122 @mail . attachments [ 'text.txt' ] = { :content => contents }
123123 encoded = @mail . encoded
124124 regex = /\r \n #{ Regexp . escape ( contents . gsub ( /\n / , "\r \n " ) ) } \r \n --#{ @mail . boundary } --\r \n \Z /
125- encoded . should match regex
125+ expect ( encoded ) . to match regex
126126 end
127127
128128 end
@@ -135,10 +135,10 @@ def check_decoded(actual, expected)
135135 mail . attachments [ 'test.gif' ] = File . open ( fixture ( 'attachments' , 'test.gif' ) , 'rb' , &:read )
136136 mail . attachments [ 'test.jpg' ] = File . open ( fixture ( 'attachments' , 'test.jpg' ) , 'rb' , &:read )
137137 mail . attachments [ 'test.zip' ] = File . open ( fixture ( 'attachments' , 'test.zip' ) , 'rb' , &:read )
138- mail . attachments [ 0 ] . filename . should eq 'test.pdf'
139- mail . attachments [ 1 ] . filename . should eq 'test.gif'
140- mail . attachments [ 2 ] . filename . should eq 'test.jpg'
141- mail . attachments [ 3 ] . filename . should eq 'test.zip'
138+ expect ( mail . attachments [ 0 ] . filename ) . to eq 'test.pdf'
139+ expect ( mail . attachments [ 1 ] . filename ) . to eq 'test.gif'
140+ expect ( mail . attachments [ 2 ] . filename ) . to eq 'test.jpg'
141+ expect ( mail . attachments [ 3 ] . filename ) . to eq 'test.zip'
142142 end
143143
144144 end
@@ -148,21 +148,21 @@ def check_decoded(actual, expected)
148148 it "should set the content_disposition to inline or attachment as appropriate" do
149149 mail = Mail . new
150150 mail . attachments [ 'test.pdf' ] = File . open ( fixture ( 'attachments' , 'test.pdf' ) , 'rb' , &:read )
151- mail . attachments [ 'test.pdf' ] . content_disposition . should eq 'attachment; filename=test.pdf'
151+ expect ( mail . attachments [ 'test.pdf' ] . content_disposition ) . to eq 'attachment; filename=test.pdf'
152152 mail . attachments . inline [ 'test.png' ] = File . open ( fixture ( 'attachments' , 'test.png' ) , 'rb' , &:read )
153- mail . attachments . inline [ 'test.png' ] . content_disposition . should eq 'inline; filename=test.png'
153+ expect ( mail . attachments . inline [ 'test.png' ] . content_disposition ) . to eq 'inline; filename=test.png'
154154 end
155155
156156 it "should return a cid" do
157157 mail = Mail . new
158158 mail . attachments . inline [ 'test.png' ] = @test_png
159- mail . attachments [ 'test.png' ] . url . should eq "cid:#{ mail . attachments [ 'test.png' ] . cid } "
159+ expect ( mail . attachments [ 'test.png' ] . url ) . to eq "cid:#{ mail . attachments [ 'test.png' ] . cid } "
160160 end
161161
162162 it "should respond true to inline?" do
163163 mail = Mail . new
164164 mail . attachments . inline [ 'test.png' ] = @test_png
165- mail . attachments [ 'test.png' ] . should be_inline
165+ expect ( mail . attachments [ 'test.png' ] ) . to be_inline
166166 end
167167 end
168168
@@ -174,17 +174,17 @@ def check_decoded(actual, expected)
174174 end
175175
176176 it "should return a content-id for the attachment on creation if passed inline => true" do
177- @cid . should_not be_nil
177+ expect ( @cid ) . not_to be_nil
178178 end
179179
180180 it "should return a valid content-id on inline attachments" do
181- Mail ::ContentIdField . new ( @cid ) . errors . should be_empty
181+ expect ( Mail ::ContentIdField . new ( @cid ) . errors ) . to be_empty
182182 end
183183
184184 it "should provide a URL escaped content_id (without brackets) for use inside an email" do
185185 @inline = @mail . attachments [ 'test.gif' ] . cid
186186 uri_parser = URI . const_defined? ( :Parser ) ? URI ::Parser . new : URI
187- @inline . should eq uri_parser . escape ( @cid . gsub ( /^</ , '' ) . gsub ( />$/ , '' ) )
187+ expect ( @inline ) . to eq uri_parser . escape ( @cid . gsub ( /^</ , '' ) . gsub ( />$/ , '' ) )
188188 end
189189 end
190190
@@ -193,7 +193,7 @@ def check_decoded(actual, expected)
193193 mail = Mail . new
194194 mail . attachments [ 'test.pdf' ] = File . open ( fixture ( 'attachments' , 'test.pdf' ) , 'rb' , &:read )
195195 mail . encoded
196- mail . mime_type . should eq 'multipart/mixed'
196+ expect ( mail . mime_type ) . to eq 'multipart/mixed'
197197 end
198198
199199 it "allows you to set the attachment before the content type" do
@@ -210,12 +210,12 @@ def check_decoded(actual, expected)
210210 it "should not raise an exception with a filename that contains a non-7bit-character" do
211211 filename = "f\u00f6 \u00f6 .b\u00e4 r"
212212 if RUBY_VERSION >= '1.9'
213- filename . encoding . should eq Encoding ::UTF_8
213+ expect ( filename . encoding ) . to eq Encoding ::UTF_8
214214 end
215215 mail = Mail . new
216- doing {
216+ expect ( doing {
217217 mail . attachments [ filename ] = File . open ( fixture ( 'attachments' , 'test.pdf' ) , 'rb' , &:read )
218- } . should_not raise_error
218+ } ) . not_to raise_error
219219 end
220220 end
221221
@@ -226,48 +226,48 @@ def check_decoded(actual, expected)
226226
227227 it "should find the attachment using content location" do
228228 mail = Mail . read ( fixture ( File . join ( 'emails' , 'attachment_emails' , 'attachment_content_location.eml' ) ) )
229- mail . attachments . length . should eq 1
229+ expect ( mail . attachments . length ) . to eq 1
230230 end
231231
232232 it "should find an attachment defined with 'name' and Content-Disposition: attachment" do
233233 mail = Mail . read ( fixture ( File . join ( 'emails' , 'attachment_emails' , 'attachment_content_disposition.eml' ) ) )
234- mail . attachments . length . should eq 1
234+ expect ( mail . attachments . length ) . to eq 1
235235 end
236236
237237 it "should use the content-type filename or name over the content-disposition filename" do
238238 mail = Mail . read ( fixture ( File . join ( 'emails' , 'attachment_emails' , 'attachment_content_disposition.eml' ) ) )
239- mail . attachments [ 0 ] . filename . should eq 'hello.rb'
239+ expect ( mail . attachments [ 0 ] . filename ) . to eq 'hello.rb'
240240 end
241241
242242 it "should decode an attachment" do
243243 mail = Mail . read ( fixture ( File . join ( 'emails' , 'attachment_emails' , 'attachment_pdf.eml' ) ) )
244- mail . attachments [ 0 ] . decoded . length . should eq 1026
244+ expect ( mail . attachments [ 0 ] . decoded . length ) . to eq 1026
245245 end
246246
247247 it "should find an attachment that has an encoded name value" do
248248 mail = Mail . read ( fixture ( File . join ( 'emails' , 'attachment_emails' , 'attachment_with_encoded_name.eml' ) ) )
249- mail . attachments . length . should eq 1
249+ expect ( mail . attachments . length ) . to eq 1
250250 result = mail . attachments [ 0 ] . filename
251251 if RUBY_VERSION >= '1.9'
252252 expected = "01 Quien Te Dij\212 at. Pitbull.mp3" . force_encoding ( result . encoding )
253253 else
254254 expected = "01 Quien Te Dij\212 at. Pitbull.mp3"
255255 end
256- result . should eq expected
256+ expect ( result ) . to eq expected
257257 end
258258
259259 it "should find an attachment that has a name not surrounded by quotes" do
260260 mail = Mail . read ( fixture ( File . join ( 'emails' , 'attachment_emails' , "attachment_with_unquoted_name.eml" ) ) )
261- mail . attachments . length . should eq 1
262- mail . attachments . first . filename . should eq "This is a test.txt"
261+ expect ( mail . attachments . length ) . to eq 1
262+ expect ( mail . attachments . first . filename ) . to eq "This is a test.txt"
263263 end
264264
265265 it "should find attachments inside parts with content-type message/rfc822" do
266266 mail = Mail . read ( fixture ( File . join ( "emails" ,
267267 "attachment_emails" ,
268268 "attachment_message_rfc822.eml" ) ) )
269- mail . attachments . length . should eq 1
270- mail . attachments [ 0 ] . decoded . length . should eq 1026
269+ expect ( mail . attachments . length ) . to eq 1
270+ expect ( mail . attachments [ 0 ] . decoded . length ) . to eq 1026
271271 end
272272
273273 it "attach filename decoding (issue 83)" do
@@ -302,7 +302,7 @@ def check_decoded(actual, expected)
302302limitMAIL
303303 mail = Mail . new ( data )
304304 #~ puts Mail::Encodings.decode_encode(mail.attachments[0].filename, :decode)
305- mail . attachments [ 0 ] . filename . should eq "Foto0009.jpg"
305+ expect ( mail . attachments [ 0 ] . filename ) . to eq "Foto0009.jpg"
306306 end
307307
308308 end
@@ -325,16 +325,16 @@ def check_decoded(actual, expected)
325325 mail . attachments [ 'test.pdf' ] = File . open ( fixture ( 'attachments' , 'test.pdf' ) , 'rb' , &:read )
326326 mail . attachments [ 'test.gif' ] = File . open ( fixture ( 'attachments' , 'test.gif' ) , 'rb' , &:read )
327327 mail . attachments [ 'test.jpg' ] = File . open ( fixture ( 'attachments' , 'test.jpg' ) , 'rb' , &:read )
328- mail . attachments [ 0 ] . filename . should eq 'test.zip'
329- mail . attachments [ 1 ] . filename . should eq 'test.pdf'
330- mail . attachments [ 2 ] . filename . should eq 'test.gif'
331- mail . attachments [ 3 ] . filename . should eq 'test.jpg'
328+ expect ( mail . attachments [ 0 ] . filename ) . to eq 'test.zip'
329+ expect ( mail . attachments [ 1 ] . filename ) . to eq 'test.pdf'
330+ expect ( mail . attachments [ 2 ] . filename ) . to eq 'test.gif'
331+ expect ( mail . attachments [ 3 ] . filename ) . to eq 'test.jpg'
332332
333333
334334 mail2 = Mail . new ( mail . encoded )
335- mail2 . attachments [ 0 ] . filename . should eq 'test.zip'
336- mail2 . attachments [ 1 ] . filename . should eq 'test.pdf'
337- mail2 . attachments [ 2 ] . filename . should eq 'test.gif'
338- mail2 . attachments [ 3 ] . filename . should eq 'test.jpg'
335+ expect ( mail2 . attachments [ 0 ] . filename ) . to eq 'test.zip'
336+ expect ( mail2 . attachments [ 1 ] . filename ) . to eq 'test.pdf'
337+ expect ( mail2 . attachments [ 2 ] . filename ) . to eq 'test.gif'
338+ expect ( mail2 . attachments [ 3 ] . filename ) . to eq 'test.jpg'
339339 end
340340end
0 commit comments