Sha256: be7bb9c1274b3c76917b7834ffaf3de5f5acd16892bd6a983a60580e414f6ab6
Contents?: true
Size: 1.17 KB
Versions: 8
Compression:
Stored size: 1.17 KB
Contents
def image_properties(image) if image.is_a?(Tempfile) tempfile = image else tempfile = Tempfile.new('image') tempfile.write(image.is_a?(Dragonfly::TempObject) ? image.data : image) tempfile.close end details = `identify #{tempfile.path}` # example of details string: # myimage.png PNG 200x100 200x100+0+0 8-bit DirectClass 31.2kb filename, format, geometry, geometry_2, depth, image_class, size = details.split(' ') width, height = geometry.split('x') { :filename => filename, :format => format.downcase, :width => width, :height => height, :depth => depth, :image_class => image_class, :size => size } end Spec::Matchers.define :have_width do |width| match do |given| width.should === image_properties(given)[:width].to_i end end Spec::Matchers.define :have_height do |height| match do |given| height.should === image_properties(given)[:height].to_i end end Spec::Matchers.define :have_format do |format| match do |given| image_properties(given)[:format].should == format end end Spec::Matchers.define :have_size do |size| match do |given| image_properties(given)[:size].should == size end end
Version data entries
8 entries across 8 versions & 2 rubygems