Sha256: 4fac55cadf175bab810d0c933fd44e5d6778710f91f8ef592e428b0cf6f6c31d

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

require "spec_helper"

RSpec.describe Fontist::Downloader do
  describe ".download" do
    it "return the valid downloaded file" do
      tempfile = Fontist::Downloader.download(
        sample_file[:file],
        sha: sample_file[:sha],
        file_size: sample_file[:file_size],
      )

      expect(tempfile).not_to be_nil
      expect(tempfile.size).to eq(sample_file[:file_size])
    end

    it "raises an error for tempared file" do
      expect{
        Fontist::Downloader.download(
          sample_file[:file],
          sha: sample_file[:sha] + "mm",
          file_size: sample_file[:file_size]
        )
      }.to raise_error(Fontist::Errors::TemparedFileError)
    end
  end

  def sample_file
    @sample_file ||= {
      file_size: 150899,
      file: "https://drive.google.com/u/0/uc?id=1Kk-rpLyQk98ubgxhTRKD2ZkMoY9KqKXk&export=download",
      sha: "5e513e4bfdada0ff10dd5b96414fcaeade84e235ce043865416ad7673cb6f3d8"
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fontist-1.0.0 spec/fontist/downloader_spec.rb