|
275 | 275 | end
|
276 | 276 |
|
277 | 277 | describe "#add_part" do
|
| 278 | + subject(:part) do |
| 279 | + described_class.new.add_part(*args) |
| 280 | + end |
| 281 | + |
| 282 | + let(:args) { [] } |
| 283 | + |
278 | 284 | it "returns the new part" do
|
279 |
| - expect(subject.add_part).to be_a(Rex::MIME::Part) |
| 285 | + expect(part).to be_a(Rex::MIME::Part) |
280 | 286 | end
|
281 | 287 |
|
282 |
| - it "sets Content-Type to text/plain by default" do |
283 |
| - part = subject.add_part |
| 288 | + it "set part's Content-Type to text/plain by default" do |
284 | 289 | expect(part.header.find('Content-Type')[1]).to eq('text/plain')
|
285 | 290 | end
|
286 | 291 |
|
287 |
| - it "sets Content-Transfer-Encoding to 8bit by default" do |
288 |
| - part = subject.add_part |
| 292 | + it "set part's Content-Transfer-Encoding to 8bit by default" do |
289 | 293 | expect(part.header.find('Content-Transfer-Encoding')[1]).to eq('8bit')
|
290 | 294 | end
|
291 | 295 |
|
292 |
| - it "doesn't set Content-Disposition by default" do |
293 |
| - part = subject.add_part |
| 296 | + it "doesn't set part's Content-Disposition by default" do |
294 | 297 | expect(part.header.find('Content-Disposition')).to be_nil
|
295 | 298 | end
|
296 | 299 |
|
297 |
| - it "allows to set up Content-Type" do |
298 |
| - part = subject.add_part('', 'application/pdf') |
299 |
| - expect(part.header.find('Content-Type')[1]).to eq('application/pdf') |
| 300 | + context "with Content-Type argument" do |
| 301 | + let(:args) { ['', 'application/pdf'] } |
| 302 | + |
| 303 | + it "creates a part Content-Type header" do |
| 304 | + expect(part.header.find('Content-Type')[1]).to eq('application/pdf') |
| 305 | + end |
300 | 306 | end
|
301 | 307 |
|
302 |
| - it "allows to set up Content-Transfer-Encoding" do |
303 |
| - part = subject.add_part('', 'application/pdf', 'binary') |
304 |
| - expect(part.header.find('Content-Transfer-Encoding')[1]).to eq('binary') |
| 308 | + context "with Content-Transfer-Encoding argument" do |
| 309 | + let(:args) { ['', 'application/pdf', 'binary'] } |
| 310 | + |
| 311 | + it "creates a part Content-Transfer-Encoding header" do |
| 312 | + expect(part.header.find('Content-Transfer-Encoding')[1]).to eq('binary') |
| 313 | + end |
305 | 314 | end
|
306 | 315 |
|
307 |
| - it "allows to set up Content-Disposition" do |
308 |
| - part = subject.add_part('', 'application/pdf', 'binary', 'attachment; filename="fname.ext"') |
309 |
| - expect(part.header.find('Content-Disposition')[1]).to eq('attachment; filename="fname.ext"') |
| 316 | + context "with Content-Disposition argument" do |
| 317 | + let(:args) { ['', 'application/pdf', 'binary', 'attachment; filename="fname.ext"'] } |
| 318 | + |
| 319 | + it "creates a part Content-Disposition header" do |
| 320 | + expect(part.header.find('Content-Disposition')[1]).to eq('attachment; filename="fname.ext"') |
| 321 | + end |
310 | 322 | end
|
311 | 323 |
|
312 |
| - it "allows to set up content" do |
313 |
| - part = subject.add_part('msfdev') |
314 |
| - expect(part.content).to eq('msfdev') |
| 324 | + context "with content argument" do |
| 325 | + let(:args) { ['msfdev'] } |
| 326 | + |
| 327 | + it "creates part content" do |
| 328 | + expect(part.content).to eq('msfdev') |
| 329 | + end |
315 | 330 | end
|
| 331 | + |
316 | 332 | end
|
317 | 333 |
|
318 | 334 | describe "#add_part_attachment" do
|
|
0 commit comments