Sha256: cebc3d290242d75fe4561841d280ff9bbd8c2cacc843d84d1dfca5d6d3b3935c

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'rspec'
require 'image_size'

describe ImageSize do
  [
    ['test.bmp',  :bmp,  50,  50],
    ['test.gif',  :gif, 668, 481],
    ['test.jpg', :jpeg, 320, 240],
    ['test.pbm',  :pbm,  85,  55],
    ['test.pcx',  :pcx,  70,  60],
    ['test.pgm',  :pgm,  90,  55],
    ['test.png',  :png, 640, 532],
    ['test.psd',  :psd,  20,  20],
    ['test.swf',  :swf, 450, 200],
    ['test.tif', :tiff,  64,  64],
    ['test.xbm',  :xbm,  16,  16],
    ['test.xpm',  :xpm,  32,  32],
    ['image_size_spec.rb', nil, nil, nil],
  ].each do |name, format, width, height|
    path = File.join(File.dirname(__FILE__), name)

    it "should get format and dimensions for #{name} given io" do
      File.open(path, 'rb') do |fh|
        is = ImageSize.new(fh)
        [is.format, is.width, is.height].should == [format, width, height]
      end
    end

    it "should get format and dimensions for #{name} given StringIO" do
      File.open(path, 'rb') do |fh|
        is = ImageSize.new(StringIO.new(fh.read))
        [is.format, is.width, is.height].should == [format, width, height]
      end
    end

    it "should get format and dimensions for #{name} given file data" do
      File.open(path, 'rb') do |fh|
        is = ImageSize.new(fh.read)
        [is.format, is.width, is.height].should == [format, width, height]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
image_size-1.0.6 spec/image_size_spec.rb