Sha256: 8f0ee5df966fe063394967f6f1c73f1a47ea754be885093d3960bb574f37f0dd

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

require "spec_helper"

RSpec.describe Fontist::Downloader do
  describe ".download", api_call: true 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::Error, "Invalid / Tempared file")
    end
  end

  def sample_file
    @sample_file ||= {
      file_size: 10132625,
      file: "https://unsplash.com/photos/ZXHgEIWELYA/download?force=true",
      sha: "b701889c51802f6f382206e6d0aa3509c8f98e10f26bd0725ae91d93e148fe7a"
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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