require 'rails_helper'

RSpec.describe Preview::UrlSafety do
  describe '.validate' do
    it 'raises UnsafeUrl when DNS resolution fails' do
      allow(Resolv).to receive(:getaddresses)
          .with('missing.example')
          .and_raise(Resolv::ResolvError)

      expect {
        described_class.validate('https://missing.example')
      }.to raise_error(Preview::UrlSafety::UnsafeUrl)
    end
  end
end
