1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
|
require 'spec_helper'
begin
# Use mime/types/columnar if available, for reduced memory usage
require 'mime/types/columnar'
rescue LoadError
require 'mime/types'
end
describe CarrierWave::SanitizedFile do
before do
FileUtils.cp(file_path('test.jpg'), file_path('llama.jpg'))
end
after do
FileUtils.rm_rf(file_path("new_dir"))
end
after(:all) do
if File.exist?(file_path('llama.jpg'))
FileUtils.rm(file_path('llama.jpg'))
end
FileUtils.rm_rf(public_path)
end
describe "#empty?" do
it "should be empty for nil" do
sanitized_file = CarrierWave::SanitizedFile.new(nil)
expect(sanitized_file).to be_empty
end
it "should be empty for an empty string" do
sanitized_file = CarrierWave::SanitizedFile.new("")
expect(sanitized_file).to be_empty
end
it "should be empty for an empty StringIO" do
sanitized_file = CarrierWave::SanitizedFile.new(StringIO.new(""))
expect(sanitized_file).to be_empty
end
end
describe '#original_filename' do
it "should default to the original_filename" do
file = double('file', :original_filename => 'llama.jpg')
sanitized_file = CarrierWave::SanitizedFile.new(file)
expect(sanitized_file.original_filename).to eq("llama.jpg")
end
it "should defer to the base name of the path if original_filename is unavailable" do
file = double('file', :path => '/path/to/test.jpg')
sanitized_file = CarrierWave::SanitizedFile.new(file)
expect(sanitized_file.original_filename).to eq("test.jpg")
end
it "should be nil otherwise" do
file = double('file')
sanitized_file = CarrierWave::SanitizedFile.new(file)
expect(sanitized_file.original_filename).to be_nil
end
end
describe "#basename" do
it "should return the basename for complicated extensions" do
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex.filename.tar.gz"))
expect(sanitized_file.basename).to eq("complex.filename")
end
it "should be the filename if the file has no extension" do
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex"))
expect(sanitized_file.basename).to eq("complex")
end
end
describe "#extension" do
%w[gz bz2 z lz xz].each do |ext|
it "should return the extension for complicated extensions (tar.#{ext})" do
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex.filename.tar.#{ext}"))
expect(sanitized_file.extension).to eq("tar.#{ext}")
end
end
it "should return the extension for real-world user file names" do
sanitized_file = CarrierWave::SanitizedFile.new(file_path("Photo on 2009-12-01 at 11.12.jpg"))
expect(sanitized_file.extension).to eq("jpg")
end
it "should return the extension for basic filenames" do
sanitized_file = CarrierWave::SanitizedFile.new(file_path("something.png"))
expect(sanitized_file.extension).to eq("png")
end
it "should be an empty string if the file has no extension" do
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex"))
expect(sanitized_file.extension).to eq("")
end
end
describe "#filename" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(nil) }
it "should default to the original filename if it is valid" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("llama.jpg")
expect(sanitized_file.filename).to eq("llama.jpg")
end
it "should remove illegal characters from a filename" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("test-s,%&m#st?.jpg")
expect(sanitized_file.filename).to eq("test-s___m_st_.jpg")
end
it "should remove slashes from the filename" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("../../very_tricky/foo.bar")
expect(sanitized_file.filename).not_to match(/[\\\/]/)
end
it "should remove illegal characters if there is no extension" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("`*foo")
expect(sanitized_file.filename).to eq("__foo")
end
it "should remove the path prefix on Windows" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return('c:\temp\foo.txt')
expect(sanitized_file.filename).to eq("foo.txt")
end
it "should make sure the *nix directory thingies can't be used as filenames" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return(".")
expect(sanitized_file.filename).to eq("_.")
end
it "should maintain uppercase filenames" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("DSC4056.JPG")
expect(sanitized_file.filename).to eq("DSC4056.JPG")
end
it "should remove illegal characters from a non-ASCII filename" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("⟲«Du côté des chars lourds»_123.doc")
expect(sanitized_file.filename).to eq("__Du_côté_des_chars_lourds__123.doc")
end
it "should default to the original non-ASCII filename if it is valid" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("тестовый.jpg")
expect(sanitized_file.filename).to eq("тестовый.jpg")
end
it "should downcase non-ASCII characters properly" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("ТестоВый Ёжик.jpg")
expect(sanitized_file.filename).to eq("ТестоВый_Ёжик.jpg")
end
end
describe "#filename with an overridden sanitize_regexp" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(nil) }
before do
allow(sanitized_file).to receive(:sanitize_regexp).and_return(/[^a-zA-Z\.\-\+_]/)
end
it "should default to the original filename if it is valid" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("llama.jpg")
expect(sanitized_file.filename).to eq("llama.jpg")
end
it "should remove illegal characters from a filename" do
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("123.jpg")
expect(sanitized_file.filename).to eq("___.jpg")
end
end
describe "#content_type" do
it "preserves file's content_type" do
sanitized_file = CarrierWave::SanitizedFile.new(content_type: "image/png")
expect(sanitized_file.content_type).to eq("image/png")
end
it "preserves file's content_type when passed as type (Rack)" do
sanitized_file = CarrierWave::SanitizedFile.new(type: "image/png")
expect(sanitized_file.content_type).to eq("image/png")
end
it "handles Mime::Type object" do
file = File.open(file_path('sponsored.doc'))
allow(file).to receive(:content_type).and_return(MIME::Type.new("application/msword"))
sanitized_file = CarrierWave::SanitizedFile.new(file)
allow(sanitized_file).to receive(:file).and_return(file)
expect { sanitized_file.content_type }.not_to raise_error
expect(sanitized_file.content_type).to eq("application/msword")
end
it "reads content type from path if missing" do
sanitized_file = CarrierWave::SanitizedFile.new("llama.jpg")
expect(sanitized_file.content_type).to eq("image/jpeg")
end
end
describe "#content_type=" do
it "sets content_type" do
sanitized_file = CarrierWave::SanitizedFile.new(content_type: "image/png")
sanitized_file.content_type = "text/html"
expect(sanitized_file.content_type).to eq("text/html")
end
end
shared_examples_for "all valid sanitized files" do
describe '#empty?' do
it "should not be empty" do
expect(sanitized_file).not_to be_empty
end
end
describe '#original_filename' do
it "should return the original filename" do
expect(sanitized_file.original_filename).to eq("llama.jpg")
end
end
describe "#filename" do
it "should return the filename" do
expect(sanitized_file.filename).to eq("llama.jpg")
end
end
describe "#basename" do
it "should return the basename" do
expect(sanitized_file.basename).to eq("llama")
end
end
describe "#extension" do
it "should return the extension" do
expect(sanitized_file.extension).to eq("jpg")
end
end
describe "#read" do
it "should return the contents of the file" do
expect(sanitized_file.read).to eq("this is stuff")
end
end
describe "#size" do
it "should return the size of the file" do
expect(sanitized_file.size).to eq(13)
end
end
describe "#move_to" do
after do
FileUtils.rm_f(file_path("gurr.png"))
end
it "should be moved to the correct location" do
sanitized_file.move_to(file_path("gurr.png"))
expect(File.exist?( file_path("gurr.png") )).to be_truthy
end
it "should have changed its path when moved" do
sanitized_file.move_to(file_path("gurr.png"))
expect(sanitized_file.path).to eq(file_path("gurr.png"))
end
it "should have changed its filename when moved" do
sanitized_file.move_to(file_path("gurr.png"))
expect(sanitized_file.filename).to eq("gurr.png")
end
it "should have changed its basename when moved" do
sanitized_file.move_to(file_path("gurr.png"))
expect(sanitized_file.basename).to eq("gurr")
end
it "should have changed its extension when moved" do
sanitized_file.move_to(file_path("gurr.png"))
expect(sanitized_file.extension).to eq("png")
end
it "should set the right permissions" do
sanitized_file.move_to(file_path("gurr.png"), 0755)
expect(sanitized_file).to have_permissions(0755)
end
it "should set the right directory permissions" do
sanitized_file.move_to(file_path("new_dir","gurr.png"), nil, 0775)
expect(sanitized_file).to have_directory_permissions(0775)
end
it "should return itself" do
expect(sanitized_file.move_to(file_path("gurr.png"))).to eq(sanitized_file)
end
it "should convert the file's content type" do
sanitized_file.move_to(file_path("new_dir","gurr.png"))
expect(sanitized_file.content_type).to eq("image/jpeg")
end
context 'target path only differs by case' do
let(:upcased_sanitized_file) { CarrierWave::SanitizedFile.new(stub_file("upcase.JPG", "image/jpeg")) }
before do
FileUtils.cp(file_path("test.jpg"), file_path("upcase.JPG"))
expect(upcased_sanitized_file).not_to be_empty
end
after(:all) do
FileUtils.rm_f(file_path("upcase.JPG"))
FileUtils.rm_f(file_path("upcase.jpg"))
end
it "should not raise an error when moved" do
expect(running { upcased_sanitized_file.move_to(upcased_sanitized_file.path.downcase) }).not_to raise_error
end
end
end
describe "#copy_to" do
after do
FileUtils.rm_f(file_path("gurr.png"))
end
it "should be copied to the correct location" do
sanitized_file.copy_to(file_path("gurr.png"))
expect(File.exist?( file_path("gurr.png") )).to be_truthy
expect(file_path("gurr.png")).to be_identical_to(file_path("llama.jpg"))
end
it "should not have changed its path when copied" do
expect(running { sanitized_file.copy_to(file_path("gurr.png")) }).not_to change(sanitized_file, :path)
end
it "should not have changed its filename when copied" do
expect(running { sanitized_file.copy_to(file_path("gurr.png")) }).not_to change(sanitized_file, :filename)
end
it "should return an object of the same class when copied" do
new_file = sanitized_file.copy_to(file_path("gurr.png"))
expect(new_file).to be_an_instance_of(sanitized_file.class)
end
it "should adjust the path of the object that is returned when copied" do
new_file = sanitized_file.copy_to(file_path("gurr.png"))
expect(new_file.path).to eq(file_path("gurr.png"))
end
it "should adjust the filename of the object that is returned when copied" do
new_file = sanitized_file.copy_to(file_path("gurr.png"))
expect(new_file.filename).to eq("gurr.png")
end
it "should adjust the basename of the object that is returned when copied" do
new_file = sanitized_file.copy_to(file_path("gurr.png"))
expect(new_file.basename).to eq("gurr")
end
it "should adjust the extension of the object that is returned when copied" do
new_file = sanitized_file.copy_to(file_path("gurr.png"))
expect(new_file.extension).to eq("png")
end
it "should set the right permissions" do
new_file = sanitized_file.copy_to(file_path("gurr.png"), 0755)
expect(new_file).to have_permissions(0755)
end
it "should set the right directory permissions" do
new_file = sanitized_file.copy_to(file_path("new_dir", "gurr.png"), nil, 0755)
expect(new_file).to have_directory_permissions(0755)
end
it "should preserve the file's content type" do
new_file = sanitized_file.copy_to(file_path("gurr.png"))
expect(new_file.content_type).to eq(sanitized_file.content_type)
end
end
end
shared_examples_for "all valid sanitized files that are stored on disk" do
describe "#move_to" do
it "should not raise an error when moved to its own location" do
expect(running { sanitized_file.move_to(sanitized_file.path) }).not_to raise_error
end
it "should remove the original file" do
original_path = sanitized_file.path
sanitized_file.move_to(public_path("blah.txt"))
expect(File.exist?(original_path)).to be_falsey
end
end
describe '#copy_to' do
it "should return a new instance when copied to its own location" do
expect(running {
new_file = sanitized_file.copy_to(sanitized_file.path)
expect(new_file).to be_an_instance_of(sanitized_file.class)
}).not_to raise_error
end
it "should not remove the original file" do
new_file = sanitized_file.copy_to(public_path("blah.txt"))
expect(File.exist?(sanitized_file.path)).to be_truthy
expect(File.exist?(new_file.path)).to be_truthy
end
end
describe "#exists?" do
it "should be true" do
expect(sanitized_file.exists?).to be_truthy
end
end
describe "#delete" do
it "should remove it from the filesystem" do
expect(File.exist?(sanitized_file.path)).to be_truthy
sanitized_file.delete
expect(File.exist?(sanitized_file.path)).to be_falsey
end
end
describe "#to_file" do
it "should return a File object" do
expect(sanitized_file.to_file).to be_a(File)
end
it "should have the same path as the SanitizedFile" do
expect(sanitized_file.to_file.path).to eq(sanitized_file.path)
end
it "should have the same contents as the SantizedFile" do
expect(sanitized_file.to_file.read).to eq(sanitized_file.read)
end
end
end
shared_examples_for "all valid sanitized files that are read from an IO object" do
describe "#read" do
it "should have an open IO object" do
expect(sanitized_file.instance_variable_get(:@file).closed?).to be_falsey
end
it "should close the IO object after reading" do
sanitized_file.read
expect(sanitized_file.instance_variable_get(:@file).closed?).to be_truthy
end
end
end
describe "with a valid Hash" do
let(:hash) {
{
"tempfile" => stub_merb_tempfile("llama.jpg"),
"filename" => "llama.jpg",
"content_type" => "image/jpeg"
}
}
let(:sanitized_file) { CarrierWave::SanitizedFile.new(hash) }
it_should_behave_like "all valid sanitized files"
it_should_behave_like "all valid sanitized files that are stored on disk"
it_should_behave_like "all valid sanitized files that are read from an IO object"
describe "#path" do
it "should return the path of the tempfile" do
expect(sanitized_file.path).not_to be_nil
expect(sanitized_file.path).to eq(hash["tempfile"].path)
end
end
describe "#is_path?" do
it "should be false" do
expect(sanitized_file.is_path?).to be_falsey
end
end
end
describe "with a valid Tempfile" do
let(:tempfile) { stub_tempfile("llama.jpg", "image/jpeg") }
let(:sanitized_file) { CarrierWave::SanitizedFile.new(tempfile) }
it_should_behave_like "all valid sanitized files"
it_should_behave_like "all valid sanitized files that are stored on disk"
it_should_behave_like "all valid sanitized files that are read from an IO object"
describe "#is_path?" do
it "should be false" do
expect(sanitized_file.is_path?).to be_falsey
end
end
describe "#path" do
it "should return the path of the tempfile" do
expect(sanitized_file.path).not_to be_nil
expect(sanitized_file.path).to eq(tempfile.path)
end
end
end
describe "with a valid StringIO" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(stub_stringio("llama.jpg", "image/jpeg")) }
it_should_behave_like "all valid sanitized files"
it_should_behave_like "all valid sanitized files that are read from an IO object"
describe "#exists?" do
it "should be false" do
expect(sanitized_file.exists?).to be_falsey
end
end
describe "#is_path?" do
it "should be false" do
expect(sanitized_file.is_path?).to be_falsey
end
end
describe "#path" do
it "should be nil" do
expect(sanitized_file.path).to be_nil
end
end
describe "#delete" do
it "should not raise an error" do
expect(running { sanitized_file.delete }).not_to raise_error
end
end
describe "#to_file" do
it "should be nil" do
expect(sanitized_file.to_file).to be_nil
end
end
end
describe "with a valid File object" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(stub_file("llama.jpg", "image/jpeg")) }
before do
FileUtils.cp(file_path("test.jpg"), file_path("llama.jpg"))
expect(sanitized_file).not_to be_empty
end
it_should_behave_like "all valid sanitized files"
it_should_behave_like "all valid sanitized files that are stored on disk"
it_should_behave_like "all valid sanitized files that are read from an IO object"
describe "#is_path?" do
it "should be false" do
expect(sanitized_file.is_path?).to be_falsey
end
end
describe "#path" do
it "should return the path of the file" do
expect(sanitized_file.path).not_to be_nil
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
end
end
end
describe "with a valid File object and an empty file" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(stub_file("llama.jpg", "image/jpeg")) }
before do
FileUtils.cp(file_path("test.jpg"), file_path("llama.jpg"))
FileUtils.rm file_path("llama.jpg")
FileUtils.touch file_path("llama.jpg")
expect(sanitized_file).not_to be_empty
end
it_should_behave_like "all valid sanitized files that are stored on disk"
it_should_behave_like "all valid sanitized files that are read from an IO object"
describe "#is_path?" do
it "should be false" do
expect(sanitized_file.is_path?).to be_falsey
end
end
describe "#path" do
it "should return the path of the file" do
expect(sanitized_file.path).not_to be_nil
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
end
end
end
describe "with a valid path" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(file_path("llama.jpg")) }
before do
FileUtils.cp(file_path("test.jpg"), file_path("llama.jpg"))
expect(sanitized_file).not_to be_empty
end
it_should_behave_like "all valid sanitized files"
it_should_behave_like "all valid sanitized files that are stored on disk"
describe "#is_path?" do
it "should be true" do
expect(sanitized_file.is_path?).to be_truthy
end
end
describe "#path" do
it "should return the path of the file" do
expect(sanitized_file.path).not_to be_nil
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
end
end
end
describe "with a valid Pathname" do
let(:sanitized_file) { CarrierWave::SanitizedFile.new(Pathname.new(file_path("llama.jpg"))) }
before do
FileUtils.copy_file(file_path("test.jpg"), file_path("llama.jpg"))
expect(sanitized_file).not_to be_empty
end
it_should_behave_like "all valid sanitized files"
it_should_behave_like "all valid sanitized files that are stored on disk"
describe "#is_path?" do
it "should be true" do
expect(sanitized_file.is_path?).to be_truthy
end
end
describe "#path" do
it "should return the path of the file" do
expect(sanitized_file.path).not_to be_nil
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
end
end
end
describe "that is empty" do
let(:empty) { CarrierWave::SanitizedFile.new(nil) }
describe "#empty?" do
it "should be true" do
expect(empty).to be_empty
end
end
describe "#exists?" do
it "should be false" do
expect(empty.exists?).to be_falsey
end
end
describe "#is_path?" do
it "should be false" do
expect(empty.is_path?).to be_falsey
end
end
describe "#size" do
it "should be zero" do
expect(empty.size).to be_zero
end
end
describe "#path" do
it "should be nil" do
expect(empty.path).to be_nil
end
end
describe "#original_filename" do
it "should be nil" do
expect(empty.original_filename).to be_nil
end
end
describe "#filename" do
it "should be nil" do
expect(empty.filename).to be_nil
end
end
describe "#basename" do
it "should be nil" do
expect(empty.basename).to be_nil
end
end
describe "#extension" do
it "should be nil" do
expect(empty.extension).to be_nil
end
end
describe "#delete" do
it "should not raise an error" do
expect(running { empty.delete }).not_to raise_error
end
end
describe "#to_file" do
it "should be nil" do
expect(empty.to_file).to be_nil
end
end
end
describe "that is an empty string" do
let(:empty) { CarrierWave::SanitizedFile.new("") }
describe "#empty?" do
it "should be true" do
expect(empty).to be_empty
end
end
describe "#exists?" do
it "should be false" do
expect(empty.exists?).to be_falsey
end
end
describe "#is_path?" do
it "should be false" do
expect(empty.is_path?).to be_falsey
end
end
describe "#size" do
it "should be zero" do
expect(empty.size).to be_zero
end
end
describe "#path" do
it "should be nil" do
expect(empty.path).to be_nil
end
end
describe "#original_filename" do
it "should be nil" do
expect(empty.original_filename).to be_nil
end
end
describe "#filename" do
it "should be nil" do
expect(empty.filename).to be_nil
end
end
describe "#basename" do
it "should be nil" do
expect(empty.basename).to be_nil
end
end
describe "#extension" do
it "should be nil" do
expect(empty.extension).to be_nil
end
end
describe "#delete" do
it "should not raise an error" do
expect(running { empty.delete }).not_to raise_error
end
end
describe "#to_file" do
it "should be nil" do
expect(empty.to_file).to be_nil
end
end
end
end
|