Sha256: 36c7c53ff580a11a5e54a752954f409ab78add29d65be09e7e7fbf82cefc09f7

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

shared_examples_for 'saving a sprite' do
  # Requires:
  #
  #   @sprite => Montage::Sprite
  #   @dir    => Pathname (path at which the sprite is saved)
  #   @output => Pathname (path for the final sprite)
  #
  it 'should save the sprite to the specified directory' do
    lambda { @sprite.write }.should \
      change(&lambda { @output.file? })
  end

  it 'should save an 8-bit PNG with transparency' do
    @sprite.write
    image = Magick::Image.ping(@output).first
    image.format.should == 'PNG'
    image.quantum_depth.should == 8 # 8-bits per channel.
  end

  it 'should overwrite an existingn file' do
    FileUtils.touch(@output)
    orig_size = @output.size
    @sprite.write

    # Using touch should create an empty file. Saving the PNG
    # should result in a larger file.
    @output.should be_file
    @output.size.should > orig_size
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
montage-0.4.0 spec/lib/shared_sprite_specs.rb