Sha256: e87fd5f014562dc3f795cc851effbeabe935ecd97820335bf9bc7b984602041b

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

require 'dply/curl'

module Dply
  describe Curl do

    let(:url) { "http://127.0.0.1:8000/build.tar.gz" }

    describe "#download(url, file)" do
      it "downloads the url to file" do
        Dir.mktmpdir do |dir|
          f = "#{dir}/f"
          curl = Curl.new
          expect(Logger.logger).to receive(:bullet).with("downloading #{url}")
          curl.download(url, f)
          expect(File).to exist(f)
        end
      end

      it "raises error when url doesn't exist" do
        url = "http://127.0.0.1:8000/build"
        Dir.mktmpdir do |dir|
          f = "#{dir}/f"
          curl = Curl.new
          expect(Logger.logger).to receive(:bullet).with("downloading #{url}")
          expect { curl.download(url, f) }.to raise_error(Error)
        end
      end

      it "logs message to debug when quiet: true" do
        Dir.mktmpdir do |dir|
          f = "#{dir}/f"
          curl = Curl.new(quiet: true)
          expect(Logger.logger).to receive(:debug).with("downloading #{url}")
          curl.download(url, f)
        end
      end
    end
  end
end


Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dply-0.3.15 spec/dply/curl_spec.rb
dply-0.3.14 spec/dply/curl_spec.rb
dply-0.3.13 spec/dply/curl_spec.rb
dply-0.3.12 spec/dply/curl_spec.rb
dply-0.3.11 spec/dply/curl_spec.rb
dply-0.3.10 spec/dply/curl_spec.rb
dply-0.3.9 spec/dply/curl_spec.rb
dply-0.3.8 spec/dply/curl_spec.rb
dply-0.3.7 spec/dply/curl_spec.rb
dply-0.3.6 spec/dply/curl_spec.rb
dply-0.3.5 spec/dply/curl_spec.rb
dply-0.3.4 spec/dply/curl_spec.rb
dply-0.3.3 spec/dply/curl_spec.rb
dply-0.3.2 spec/dply/curl_spec.rb
dply-0.3.1 spec/dply/curl_spec.rb
dply-0.3.0 spec/dply/curl_spec.rb