Sha256: 3b3d8b5eafd473c65ef7f9ee47fcc673027b3dd7ecc7d2f54dc38ab5fdb508b4

Contents?: true

Size: 1.64 KB

Versions: 24

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe ChunkyPNG::Canvas::Masking do
  
  subject { reference_canvas('clock') }

  before(:all) do
    @theme_color      = ChunkyPNG::Color('#e10f7a')
    @new_color        = ChunkyPNG::Color('#ff0000')
    @background_color = ChunkyPNG::Color('white')
  end
  
  describe '#change_theme_color!' do
    it "should change the theme color correctly" do
      subject.change_theme_color!(@theme_color, @new_color)
      subject.should == reference_canvas('clock_updated')
    end
  end
  
  describe '#extract_mask' do
    it "should create the correct base and mask image" do
      base, mask = subject.extract_mask(@theme_color, @background_color)
      base.should == reference_canvas('clock_base')
      mask.should == reference_canvas('clock_mask')
    end
    
    it "should create a mask image with only one opaque color" do
      base, mask = subject.extract_mask(@theme_color, @background_color)
      mask.palette.opaque_palette.size.should == 1
    end
  end
  
  describe '#change_mask_color!' do
    before { @mask = reference_canvas('clock_mask') }
    
    it "should replace the mask color correctly" do
      @mask.change_mask_color!(@new_color)
      @mask.should == reference_canvas('clock_mask_updated')
    end
    
    it "should still only have one opaque color" do
      @mask.change_mask_color!(@new_color)
      @mask.palette.opaque_palette.size.should == 1
    end
    
    it "should raise an exception when the mask image has more than once color" do
      not_a_mask = reference_canvas('operations')
      lambda { not_a_mask.change_mask_color!(@new_color) }.should raise_error(ChunkyPNG::ExpectationFailed)
    end
  end
end

Version data entries

24 entries across 23 versions & 4 rubygems

Version Path
bench9000-0.1 vendor/chunky_png/spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.3.2 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.3.1 spec/chunky_png/canvas/masking_spec.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/chunky_png-1.3.0/spec/chunky_png/canvas/masking_spec.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/chunky_png-1.3.0/spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.3.0 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.9 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.8 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.7 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.6 spec/chunky_png/canvas/masking_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/chunky_png-1.2.5/spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.5 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.4 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.3 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.2 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.1 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.2.0 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.1.2 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.1.1 spec/chunky_png/canvas/masking_spec.rb
chunky_png-1.1.0 spec/chunky_png/canvas/masking_spec.rb