Sha256: 1e2ca61523b2275403022908089e3f58d0609fedbf67a0b0529feb96155ee466

Contents?: true

Size: 1.19 KB

Versions: 30

Compression:

Stored size: 1.19 KB

Contents

# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Kindai::SpreadDownloader do
  before do
    @book = Kindai::Book.new_from_permalink('http://kindai.ndl.go.jp/info:ndljp/pid/922693')
    @spread = @book.spreads[10]
    @downloader   = Kindai::SpreadDownloader.new_from_spread(@spread)
  end

  it 'has spread' do
    @downloader.spread.should == @spread
  end

  it 'has retry_count' do
    @downloader.retry_count.should == 30
    @downloader.retry_count = 50
    @downloader.retry_count.should == 50
  end

  it 'has spread path' do
    @downloader.book_path = "/path/to/book"
    @downloader.spread_path.should == "/path/to/book/original/011.jpg"
  end

  it 'can download spread' do
    book_path = File.join(ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp', rand.to_s)
    Dir.mkdir(book_path)
    @downloader.book_path = book_path

    @downloader.has_file?.should be_false
    @downloader.download.should be_true
    @downloader.has_file?.should be_true
    @downloader.download.should be_false

    @downloader.delete.should be_true
    FileUtils.rm_r book_path

    @downloader.has_file?.should be_false
    @downloader.delete.should be_false
  end


end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
kindai-2.8.0 spec/spread_downloader_spec.rb
kindai-2.7.0 spec/spread_downloader_spec.rb
kindai-2.6.0 spec/spread_downloader_spec.rb
kindai-2.5.1 spec/spread_downloader_spec.rb
kindai-2.4.3 spec/spread_downloader_spec.rb
kindai-2.4.2 spec/spread_downloader_spec.rb
kindai-2.4.1 spec/spread_downloader_spec.rb
kindai-2.4.0 spec/spread_downloader_spec.rb
kindai-2.3.0 spec/spread_downloader_spec.rb
kindai-2.2.1 spec/spread_downloader_spec.rb
kindai-2.2.0 spec/spread_downloader_spec.rb
kindai-2.1.2 spec/spread_downloader_spec.rb
kindai-2.1.1 spec/spread_downloader_spec.rb
kindai-2.1.0 spec/spread_downloader_spec.rb
kindai-2.0.0 spec/spread_downloader_spec.rb
kindai-1.9.0 spec/spread_downloader_spec.rb
kindai-1.8.0 spec/spread_downloader_spec.rb
kindai-1.7.4 spec/spread_downloader_spec.rb
kindai-1.7.2 spec/spread_downloader_spec.rb
kindai-1.7.1 spec/spread_downloader_spec.rb