Sha256: d741847d461ea2fabaf48633639b9276a3bc82626194ae0a5c578c9d1cd26a3c

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

require 'simple_pvr'

module SimplePvr
  describe ProgrammeIconFetcher do
    before do
      @recording_dir = File.dirname(__FILE__) + '/../resources/recordings'
      FileUtils.rm_rf(@recording_dir) if Dir.exists?(@recording_dir)
      FileUtils.mkdir_p(@recording_dir)
    end
    
    it 'fetches image and stores it in specified location' do
      destination_file = "#{@recording_dir}/dummyImage.png"

      # We're using open-uri, which unfortunately does not understand file://, which would be perfect for
      # this unit test. However, URLs starting with / are apparently interpreted as normal files.
      source_url = "#{File.dirname(__FILE__)}/../resources/dummyImage.png"

      Thread.should_receive(:new).and_yield
      
      ProgrammeIconFetcher.fetch(source_url, destination_file)
      
      File.read(destination_file).should == 'This is not really a PNG file...'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_pvr-1.1.0 spec/simple_pvr/programme_icon_fetcher_spec.rb