File: changed_predicate_spec.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (31 lines) | stat: -rw-r--r-- 871 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
31
RSpec.describe Magick::Image, "#changed?" do
  it "returns true when a new image is instantiated" do
    image = described_class.new(2, 2)

    expect(image.changed?).to be(true)
  end

  it "returns false after an image is loaded from disk" do
    image = described_class.read(FLOWER_HAT).first

    expect(image.changed?).to be(false)
  end

  it "returns true when a pixel in the image was changed" do
    image = described_class.read(FLOWER_HAT).first

    image.import_pixels(0, 0, 1, 1, "RGB", [45, 98, 156])

    expect(image.changed?).to be(true)
  end

  it "still returns true after it has been persisted" do
    image = described_class.read(FLOWER_HAT).first

    Dir.mktmpdir do |tmp|
      image.import_pixels(0, 0, 1, 1, "RGB", [45, 98, 156])
      image.write("#{tmp}/test_changed_predicate.jpg")
      expect(image.changed?).to be(true)
    end
  end
end