# This is kind of slow. Consider stubbing RMagick calls if it gets too cumbersome
describe Support::Helpers::Image do
  let(:same_image) { File.join(Support::Paths.assets, "artwork", "flaming_t", "original.jpg") }
  let(:different_image) { File.join(Support::Paths.assets, "artwork", "3k_300_rgb", "original.jpg") }
  let(:dimension_mismatch) { File.join(Support::Paths.assets, "artwork", "3k_300_rgb", "large_cover.jpg") }

  subject { described_class.new(same_image) }

  describe "#matches?" do
    it "returns true for same image" do
      expect(subject.matches?(same_image)).to be true
    end

    it "returns false for different image" do
      expect(subject.matches?(different_image)).to be false
    end

    it "fails for dimension mismatch" do
      expect { subject.matches?(dimension_mismatch) }.to raise_error RuntimeError
    end
  end

  describe "#should_match" do
    it "passes for same image" do
      expect { subject.should_match(same_image) }.not_to raise_error
    end

    it "fails for different image" do
      expect { subject.should_match(different_image) }.to raise_error RuntimeError
    end

    it "fails for dimension mismatch" do
      expect { subject.should_match(dimension_mismatch) }.to raise_error RuntimeError
    end
  end
end
