File: composite_spec.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (30 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
RSpec.describe Magick::Draw, '#composite' do
  it 'works' do
    draw = described_class.new
    image = Magick::Image.new(10, 10)

    expect { draw.composite(0, 0, 10, 10, image) }.not_to raise_error

    Magick::CompositeOperator.values do |op|
      expect { draw.composite(0, 0, 10, 10, image, op) }.not_to raise_error
    end

    expect { draw.composite('x', 0, 10, 10, image) }.to raise_error(TypeError)
    expect { draw.composite(0, 'y', 10, 10, image) }.to raise_error(TypeError)
    expect { draw.composite(0, 0, 'w', 10, image) }.to raise_error(TypeError)
    expect { draw.composite(0, 0, 10, 'h', image) }.to raise_error(TypeError)
    expect { draw.composite(0, 0, 10, 10, image, Magick::CenterAlign) }.to raise_error(TypeError)
    expect { draw.composite(0, 0, 10, 10, 'image') }.to raise_error(NoMethodError)
    expect { draw.composite(0, 0, 10, 10) }.to raise_error(ArgumentError)
    expect { draw.composite(0, 0, 10, 10, image, Magick::ModulusAddCompositeOp, 'x') }.to raise_error(ArgumentError)
  end

  it 'accepts an ImageList argument' do
    draw = described_class.new

    image_list = Magick::ImageList.new
    image_list.new_image(10, 10)
    expect { draw.composite(0, 0, 10, 10, image_list) }.not_to raise_error
    expect { draw.composite(0, 0, 10, 10, image_list, Magick::BlendCompositeOp) }.not_to raise_error
  end
end