Sha256: 5c431d721929dc17ae7f8c587ad1838aec7b1dcb8c443e63ea107d5f22532181

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require "refile"

RSpec.describe Refile do
  let(:io) { StringIO.new("hello") }

  describe ".verify_uploadable" do
    it "works if it conforms to required API" do
      expect(Refile.verify_uploadable(double(size: 444, read: io, eof?: true, close: nil), nil)).to be_truthy
    end

    it "raises ArgumentError if argument does not respond to `size`" do
      expect { Refile.verify_uploadable(double(read: io, eof?: true, close: nil), nil) }.to raise_error(ArgumentError)
    end

    it "raises ArgumentError if argument does not respond to `read`" do
      expect { Refile.verify_uploadable(double(size: 444, eof?: true, close: nil), nil) }.to raise_error(ArgumentError)
    end

    it "raises ArgumentError if argument does not respond to `eof?`" do
      expect { Refile.verify_uploadable(double(size: 444, read: true, close: nil), nil) }.to raise_error(ArgumentError)
    end

    it "raises ArgumentError if argument does not respond to `close`" do
      expect { Refile.verify_uploadable(double(size: 444, read: true, eof?: true), nil) }.to raise_error(ArgumentError)
    end

    it "returns true if size is respeced" do
      expect(Refile.verify_uploadable(Refile::FileDouble.new("hello"), 8)).to be_truthy
    end

    it "raises Refile::Invalid if size is exceeded" do
      expect { Refile.verify_uploadable(Refile::FileDouble.new("hello world"), 8) }.to raise_error(Refile::Invalid)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refile-0.3.0 spec/refile_spec.rb
refile-0.2.5 spec/refile_spec.rb
refile-0.2.4 spec/refile_spec.rb
refile-0.2.3 spec/refile_spec.rb
refile-0.2.2 spec/refile_spec.rb