Class: Use

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
Downloader
Defined in:
lib/test/tc_download.rb

Instance Method Summary collapse

Methods included from Downloader

#download, #placed

Instance Method Details

#setupObject

init …



7
8
9
10
11
# File 'lib/test/tc_download.rb', line 7

def setup()
    @dir = "./img"
    @direxist = Dir.exist?(@dir)
    @test_src = 'https://w.wallhaven.cc/full/r2/wallhaven-r2qqlj.jpg'
end

#teardownObject

destroy …



21
22
23
24
# File 'lib/test/tc_download.rb', line 21

def teardown()
    File.delete(self.placed) if self.placed && File.exist?(self.placed)
    Dir.rmdir(@dir) unless @direxist
end

#test_downloadObject



12
13
14
15
16
17
18
19
# File 'lib/test/tc_download.rb', line 12

def test_download()
    begin
        self.download(@test_src)
        assert(File.exist?(self.placed), 'download failed')
    rescue => exception
        assert(false, "download exception: #{exception.message}")
    end
end