Sha256: 8dc42acccc0c0d4194c9a0d50d49ffb7cba13e7af198532235813f721515c156
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 KB
Contents
require 'spec_helper' describe Dragonfly::ImageMagick::Analyser do before(:each) do @image = Dragonfly::TempObject.new(SAMPLES_DIR.join('beach.png')) @analyser = Dragonfly::ImageMagick::Analyser.new end it "should return the width" do @analyser.width(@image).should == 280 end it "should return the height" do @analyser.height(@image).should == 355 end it "should return the aspect ratio" do @analyser.aspect_ratio(@image).should == (280.0/355.0) end it "should say if it's portrait" do @analyser.portrait?(@image).should be_true end it "should say if it's landscape" do @analyser.landscape?(@image).should be_false end it "should return the number of colours" do @analyser.number_of_colours(@image).should == 34703 end it "should return the depth" do @analyser.depth(@image).should == 8 end it "should return the format" do @analyser.format(@image).should == :png end %w(width height aspect_ratio number_of_colours depth format portrait? landscape?).each do |meth| it "should throw unable_to_handle in #{meth.inspect} if it's not an image file" do suppressing_stderr do temp_object = Dragonfly::TempObject.new('blah') lambda{ @analyser.send(meth, temp_object) }.should throw_symbol(:unable_to_handle) end end end it "should say if it's an image" do @analyser.image?(@image).should == true end it "should say if it's not an image" do suppressing_stderr do @analyser.image?(Dragonfly::TempObject.new('blah')).should == false end end it "should work for images with spaces in the filename" do image = Dragonfly::TempObject.new(SAMPLES_DIR.join('white pixel.png')) @analyser.width(image).should == 1 end it "should work (width) for images with capital letter extensions" do image = Dragonfly::TempObject.new(SAMPLES_DIR.join('DSC02119.JPG')) @analyser.width(image).should == 1 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dragonfly-0.9.15 | spec/dragonfly/image_magick/analyser_spec.rb |
dragonfly-0.9.14 | spec/dragonfly/image_magick/analyser_spec.rb |
dragonfly-0.9.13 | spec/dragonfly/image_magick/analyser_spec.rb |